1. Principles of OOP #

Created Wednesday 08 January 2020

What is OOP #

Principles of OOP #

There are 4:

  1. Encapsulation - practice of combining variables(data) and relevant functions into a single unit.
    • Solution - Minimizes parameters, consequently minimizing arguments.
    • Context in C++ - class
  2. Abstraction - process of hiding parts of the program for maintainability purposes.
    • Solution - Simplifies the interface. Reduces the impact of change, i.e we can have a complex and flexible web of helper functions, but the interface remains the same.
    • Context in C++ - Access control, viz public, private and protected, enforce ‘data hiding’, which is the ‘tool’ used to achieve abstraction.
  3. Inheritance
    • Solution - Eliminates redundant code.
    • Context in C++ - Parent class are specified when defining a class, using the ‘:’ symbol.
  4. Polymorphism
    • Solution - Eliminates if/else and switch statements. Code context based functions.
    • Context in C++ - The compiler chooses the relevant version of the function. We don’t have to specify while calling.

Visibility - Abstraction #

Visibility(access of members using object) is controlled using three keywords:

  1. Public
  2. Private
  3. Protected

FIXME: Modifers