+ 5

I can't bring myself to learn about classes

I'm learning Python. Recently, I managed to purchase an Udemy course. As I was going through the course, I find myself hitting a wall right after the topic about "functions". This particular chapter deals with OOP and classes. I've attempted many different forms of medium for learning and practicing OOP - Online courses, videos, other external resource that I can find. I often feel demotivated and I find that my memory, at the end of the day, retains nothing about classes. I know that laziness can be a factor, but why is this especially apparent when it comes to OOP? What would be the correct approach to master OOP, especially for beginners, in Python?

7th Feb 2020, 11:59 PM
Duncan
Duncan - avatar
7 Respostas
+ 7
Not every learning style works for everyone. Try a good book maybe? Or you just write a lot of code and google what you need? EDIT: Wait - you were talking about classes as in OOP, right? 😂 I think we will only start to use higher structure elements when we feel they become necessary. If all our programs are 20 lines long, we won't ever even feel the need for functions. As soon as we're writing hundred lines or more... it gradually gets more messy. Suddenly we see that functions help. Classes also need a certain complexity/size of code until you actually start to feel that you get a better overview by using them. So basically you'll only need to write code, increasing the scope of your projects. Naturally, at some point, you'll start to think: This is too messy... what can I do?
8th Feb 2020, 12:03 AM
HonFu
HonFu - avatar
+ 4
Duncan I know from brief conversation with you that you are a smarter person. As far as questions and answers it doesn't appear to be a question but thoughts... Udemy has some good courses... and you are not on anybody's timeframe that I know of... Keep practicing you'll get there... Believing is healing Thanks please follow the guidelines https://www.sololearn.com/discuss/1316935/?ref=app
8th Feb 2020, 12:09 AM
BroFar
BroFar - avatar
+ 4
Duncan I’m so glad you shared this! I feel the same way. I was excited to learn about lists and strings and functions, but I have a mental block against reading or watching videos about classes. The information just doesn’t register. And HonFu - thank you so much for your insight on necessity. That makes a lot of sense. So I would argue that Duncan’s observation does belong here. I, for one, really benefitted from your explanation and I think other new learners might also.
8th Feb 2020, 2:26 AM
Isabel
Isabel - avatar
+ 4
Think it this way- - A class is a container which contains Variables and Functions (known as Methods) - Every Variable and Method are known as the member of the class - Members can be accessed by the dot(.) operator. Actually, it is easy to know what is a class and It is hard to learn it's possibilities.
9th Feb 2020, 1:51 PM
Terminal_Phantom
Terminal_Phantom - avatar
+ 3
Part 1/2 Duncan I understand your frusration. I went through something simmilar. Firstly let's turn this into a valid question for the Q/A section. Add to the end of the title something like. "What don't I understand about classes" And at the end of the text. "I suspect it is because I cannot see the value in using classes. What do I need to understand to want to use classes?" HonFu makes a good point elsewhere in this thread. The penny dropped for me when I realised that I don't need to name a variable for each class assignment. The examples might show (Python) (Example construed to enhance my point) class Dog: def __init__(self, name, age): self.name = name.title() self.age = age Fido = Dog(name='Fido', age=4) print("Dog's name is " + Fido.name + ".") I would have to know the name of the dog to get the name of the dog. I just thought classes were dumb. Continuation following.....
8th Feb 2020, 5:48 AM
Louis
Louis - avatar
+ 3
.....Continuation Part 2/2. The penny dropped when I saw this code by Rull Deef đŸș . (There are so many briliant coders on SL from which I have learned so much.) https://code.sololearn.com/WT4BSDOiHRe3/?ref=app The output is so mesmerizing Line 26 for(let i = 0; i < birdCount; i++) birds.push(new Bird) Just created 30 birds of Bird class Line 37, 38 birds.map(bird => bird.update()) birds.map(bird => bird.render()) Just updated 30 birds and redrawed them in 2 lines without knowing their names. Now doesn't that make you look at clases differently?
8th Feb 2020, 5:50 AM
Louis
Louis - avatar
0
Hi Duncan! I understand where you are stuck because i also was facing this before some time but now i become very familier to it. But no problem.. Keep coding oop. Try to use it as much as u can. then you will soon get easy with it. Thanks 😊
9th Feb 2020, 9:25 PM
Khansa Ashraf
Khansa Ashraf - avatar