Intermediate Python Object Oriented Programming
Transcript from the "Object Oriented Programming" Lesson
>> Nina Zakharenko: Next, we're gonna talk about, classes, objects and object oriented programming. Object oriented programming, it allows us to represent our code in a much different way. Organized intaclasses. The concept of object oriented programming, it's a language model or a paradigm where properties or behaviors are organized into objects.
[00:00:25] Some programming languages, they encourage a more procedural style, like COBOL or BASIC. You just go through everything step by step. You're not jumping to other parts of the program necessarily. But more modern languages, they tend to adopt an object oriented style to organize things into objects and provide methods for those objects to communicate with each other.
>> Nina Zakharenko: So what is an object? In Python, it can be a function, it could be a variable, a property, it could be a class. Everything in Python is an object. It's a very kind of important concept. When you think of some type of languages, like Java, it has these, what you can think of, primitive types, like an int.
>> Nina Zakharenko: And that int is just kind of a very bare bones, kind of more down to the level type of,
>> Nina Zakharenko: Type, it's not an object. Whereas in Python, as we saw, even the integers, they're an object. You can call a method on them. So in Python everything is an object.
>> Nina Zakharenko: You can think of the objects that we're gonna make kind of like a generic container.
>> Nina Zakharenko: We can even make our own objects that maybe look something like a list. To do that, you would have to use magic methods, which I'm not going to cover today, but something to keep into mind.
>> Nina Zakharenko: And if you wanted to make your object that looks kind of a list, you might have some helper methods on it. Like code that might be executed on the whole list or maybe some of the items on the list. Just a way to group these concepts together.
[00:02:27] Python buys pretty heavily into this object oriented model. But that doesn't mean that you always have to use objects or classes in your programs. Python also, as we've seen, works perfectly fine in a procedural sort of way.
>> Nina Zakharenko: Like a scripting language, where one command is just executed one after the other like a recipe.
[00:02:49] But as you get familiar with object oriented programming, as you read more Python code written by other people, you'll really learn to help you encapsulate your thinking, encapsulate your code into objects for better organization, and readability, and reuse. And maintainability, code maintainability is always important. So objects in Python, they're center stage.
[00:03:16] Representing not just the data, but the overall structure of your programs.