- Most popular languages are OOP
- It is a method of programming that attempts to model some process or thing in the world as a class or object
- A VERY NICE TO HAVE WAY OF THINKING
Classes/Objects
- Class
- Blueprints for objects.
- Contains methods (functions) and attributes (similar to keys in a dict)
- Object
- Instances of classes
- Objects constructed from a class blueprint that contain their class’s methods and properties
Example: Deck of cards
- private
- use underscore in front of variable (convention)
- python has no strict enforcement of private variables (like other languages such as C#)
Encapsulation
Grouping of public and private attributes/methods into a programmatic class, making abstraction possible
- Key aspects
- Data hiding - protects an objects data/internal state from outside
- exposing only what’s necessary
- public interfaces
- functions that allow interaction with external code
- Data hiding - protects an objects data/internal state from outside
- Not exposing information as much as possible - the bare minimum, keep it “encapsulated”
Abstraction
Exposing only the relevant data in a class interface, hiding the private attributes and methods (the “inner workings”) from users