Object-oriented programming

Object-oriented programming is a programming paradigm that extends the imperative programming approach by organizing code in a way that collects logic and data together into units called objects. Objects contain data in the form of fields called attributes and procedures called methods.

Classes or prototypes are like a blueprints for an object. It contains no data but rather defines what attributes and methods an instance of the class may contain. An instance inherits the structure provided by the class or prototype.

Basic concepts

The four basic concepts of object oriented programming are inheritance, abstraction, polymorphism, and encapsulation.

SOLID design principles

  • Single responsibility - high cohesion
  • Open/closed - open for extension but closed for modification
  • Liskov substitution - if S is a subtype of T, a object of type T may be substituted with any object of subtype S
  • Interface segregation - many client-specific interfaces are better than one general-purpose interface
  • Dependency inversion - depend upon abstractions; not concretions