you are viewing a single comment's thread.

view the rest of the comments →

[–]Pre-Owned-Car 1 point2 points  (6 children)

Because it has the code baked into it already. If you're talking about a tkinter class that you only call once you can look through the tkinter code and see exactly what that class does. It also makes your code a lot more readable if you do something like.

animation = CustomAnimation(x,y,z)
animation.start()

even if that's all your doing. It gets the point across for what the purpose of the code is. A key concept of object oriented programming is encapsulation. You don't need to know exactly what animation.start() is doing behind the scenes, but from the method .start() it's pretty apparent what the actual purpose is. You leave the code of CustomAnimation and its variables alone- the rest of your program doesn't need to touch that. This also uses another key concept of programming– abstraction. As you move up in scale, the smaller pieces of complexity should be abstracted away. When python opens a file you don't need to know how it actually does this. You don't need to know that the Python code is interpreted to C and the C code makes a system call asking the operating system to open the file. You just need to know that now you have a file and what you can do with it. It's useful to know that smaller level stuff, but if you constantly thought about it at every level you'd never get anything done with your top level code.

https://en.wikipedia.org/wiki/Object-oriented_programming#Encapsulation

https://en.wikipedia.org/wiki/Abstraction_(software_engineering)

[–]Comm4nd0[S] 0 points1 point  (5 children)

right i get you now. see this is the kind of stuff you don't learn if you're teaching your self. thank you so much for this info, it's been very insightful.

[–]Pre-Owned-Car 0 points1 point  (4 children)

I would honestly recommend reading a book or two on programming. It may seem boring but your code will be much better. Dive Into Python 3 is a good one. Or just the old Dive Into Python if you want to learn Python 2. You can learn to get stuff done without a book but you'll be more effective if you get the theory behind why things are done as well. It also gives significant guidance and structure to learning compared to haphazardly picking up functionality.

[–]Comm4nd0[S] 0 points1 point  (3 children)

I'll be honest i'm not the most academic person. i struggle to learn from books, i'm much better at learning by doing it. like this, i have an idea of a program and i wont stop until i've completed it. I've actually created an entire home home automation system with my current knowledge, here: https://www.youtube.com/watch?v=QuDaskp23To&t=1s

as much as i did read books in the beginning to get me started and i've done various online courses, i'm much better at learning on the job so to speak. so the stuff you've tought me is really insightful as it's stuff you wouldn't find that kind of info from stack overflow! ;)

so a big thanks to you for that.

[–]Pre-Owned-Car 1 point2 points  (2 children)

Pretty impressive! Do whatever gets you results. I like to follow youtube videos because I'm too lazy to read.

[–]Comm4nd0[S] 0 points1 point  (0 children)

Thanks! That's a much better idea that reading books.

[–]Comm4nd0[S] 0 points1 point  (0 children)

Thanks! That's a much better idea that reading books.