FINLANDIA SCHOOLObject Oriented Programming is a way of thinking and structuring codes. it is about modelling your program around real word "objects" (like a student, a Car, a Bank account) that have properties and actions.
THE CORE CONCEPTS: CLASS AND OBJECT
1. CLASS: A blueprint for creating objects.
A Class defines the common properties and behaviors that its objects will have e. g. The architectural plan for a house is the class. It defines that a house will have "walls", "a roof" and "doors".
2. OBJECT (or instance): A specific instance of a class. It is the actual thing built from the blueprint.
Analogy: The actual ting you build from the plan is the object. Your house and neighbor's house are two different objects of the same house class.
ATTRIBUTES AND METHODS
Attributes are the properties or data that an object holds. They are variables that belong to the class. E.g. For a Car class, attributes would be colour, brand, model, current_speed.
Methods are the actions or behaviours that an object can perform. They are functions that belong to the class. E.g. For a Car Class, methods would be start_engine(), accelerate(), brake()
THE FOUR PILLARS OF OOP
1. ENCAPSULATION: Bunding the data(attributes) and the code(methods) that acts on that data into a single unit(the object). It also means hiding the object's internal details and protecting data from outside interference.
2. Inheritance: A mechanism where a new class (the "child" or "subclass") automatically inherits all the attributes and methods from the existing class( the "parent" or "superclass")
3. Polymorphism: The ability for an object, method or variable to be treated as more than one type. It allows a single action or method name to be used for different types of objects.
4. Abstraction: Hiding complex implementation details and showing only the essential features to the user.