When I ask people — in my corporate training, or when they join my “Better developers” newsletter — what frustrations they have with Python, many people say that it’s object-oriented programming. Even if they have a decent background in procedural (i.e., traditional, non-OO) development, objects confuse and surprise them.
That’s a shame, because the whole point of objects is to help us organize our code better, to make it easier to both develop and maintain programs.
A lot of introductions to objects focus on the “how,” talking about syntax — creating classes, defining methods, and the like. But I haven’t seen a lot of discussions of the “why,” or comparing how you would accomplish something without objects vs. how you would do so with them.
In this short (15-minute) video, I provide just this sort of introduction, using Python as the language. I first show how I can use tuples and functions to accomplish a simple task, and then show how you can use a class and methods to do the same thing. After watching this video, I hope that you’ll have a better sense of why and when we can use objects, and what advantages they can give us.
Questions or comments? Let me know here, on Twitter (@reuvenmlerner), or even via e-mail, at reuven@lerner.co.il.