Objected Oriented Programming(OOP)

Classes represent concepts. Objects are instances of classes.


A class is like a blueprint for creating objects.

a new class will have:

  • Properties or states (characteristics): that describe an object
  • behavior (what can it do or what can it be done to it)

both are modified through:

  • attributes: parameters that define the state of the object
  • methods: functions that define the behavior of the object

Concepts in OOP:

  • SOLID Principles
  • Encapsulation: states and behaviors are closed in one single unit.
  • Abstraction: abstraction hides the internal implementation of attributes and methods, giving external agents only what they need.
  • Inheritance: Deriving a class from another class.
  • Polymorphism: The ability to substitute classes with similar functionality.
    • Method Overriding(Dynamic Polymorphism): when subclass changes (overrides) the method (function) of the superclass.
    • Method Overloading(Static Polymorphism): When method binding(linking a method to the call) happens at compile time and it depends on the reference of the class.
    • Duck Typing: an object is of a given type if it has all methods and properties required by that type. I.e. methods and properties identify object’s type, not it’s inheritance.
  • Inheritance Relationships: Inheritance Relationships can be either “Is-A”, or “Has-A”.