+ 2

In general programming, what is the actual purpose of classes? Wouldn't typical functions work just well?

29th Jun 2018, 3:46 PM
Nick
Nick - avatar
12 Answers
+ 16
if done right, classes help the code become more modular. You can create multiple objects that do the same thing with different values or slight modifications. Help shorten code. Prevents repeated code. Yes typical functions work just as well, but you'll need MANY variables to store what that function returns. It may not be evident in small programs, but when it gets large, it gets ugly and messy! Calsses are a beautiful thing! If you ever try a language without classes you'll miss them so much! Maybe even cry!!!
29th Jun 2018, 4:04 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 11
Nick lol. They arent very useful with small programs; functions are actually preferred. Once you go huge, classes will come into play and you'll see the use... hopefully xD
29th Jun 2018, 4:09 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 11
GODOFPC ouch. lol Dont rush it. it takes time ;) Dont do much python so i dont know any good resources xD but classes in general are all the same
29th Jun 2018, 5:45 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 11
GODOFPC oh good ;) Yes classes are extremely important xD you'll see them everywhere with compatible languages
29th Jun 2018, 5:52 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
+ 7
「HAPPY TO HELP」 That way I learned OOP in python was like eating rice with fork I hope to work with classes soon 😇
29th Jun 2018, 5:34 PM
ᏳoƊoԲᎮc !
ᏳoƊoԲᎮc ! - avatar
+ 6
「HAPPY TO HELP」 Yea to be comfortable with them I need practice I have some books of python will reach oop soon 🤩 and also The video Marco told about Whenever I see any software source code the only thing I found is classes 😓😂
29th Jun 2018, 5:50 PM
ᏳoƊoԲᎮc !
ᏳoƊoԲᎮc ! - avatar
+ 5
Marco Polidori lol soup xD Thanks man I will look up for it 😊
29th Jun 2018, 5:43 PM
ᏳoƊoԲᎮc !
ᏳoƊoԲᎮc ! - avatar
+ 3
GODOFPC as long as it is not like eatin soup with a fork 😉
29th Jun 2018, 5:38 PM
Marco Polidori
Marco Polidori - avatar
+ 2
there is actually a very nice tutorial on youtube on oop in python by Corey Schafer if you are interested.
29th Jun 2018, 5:40 PM
Marco Polidori
Marco Polidori - avatar
+ 1
classes are used to store data and methods, functions aren't
29th Jun 2018, 3:58 PM
hinanawi
hinanawi - avatar
+ 1
「HAPPY TO HELP」 Yes, I've known Python for a while, but have never previously found a real use for classes. Lol
29th Jun 2018, 4:07 PM
Nick
Nick - avatar
+ 1
classes are much better at describing attributes of objects that are reused often. in other words, writing a class that is called only once in your program can probably be better handled as a method/function. if you have to the same things over and over, especially creating objects with the same attributes, classes will save you a lot of work. that of course also applies if you write methods that shall be used by other coders. a good example is UI programming. you might need 3 push buttons 5 fields etc. you don’t want to reinvent the wheel and plaster your code with repetitive stuff. instead, you call the button class from Qt and pass the features you want e.g. hope this makes sense
29th Jun 2018, 4:09 PM
Marco Polidori
Marco Polidori - avatar