Object Oriented Design Principles - RJAE5/2143-OOP GitHub Wiki

Object-Oriented Design Principles

The Object-Oriented Design (OOD) principles provide guidelines and best practices for designing software in an object-oriented way, emphasizing modularity, maintainability, and reusability. These principles aim to make systems more flexible and easier to manage. The first 5 major OOD principles are concepts of how OOP generally works using while the latter 5 are known as the SOLID Principles and subsequently will be discussed in their own page.

  • Encapsulation
    • The concept of bundling data types together in classes to create more complex objects
  • Abstraction
    • The concept of reducing complexity by limiting unnecessary information to the surface level user
  • Inheritance
    • The functionality of carrying over attributes and methods from one class to another and adding onto them
    • Use when the class exhibits the "IS-A" relationship: A car IS-A vehicle. meaning a class Car would inherit from a class Vehicle.
  • Composition
    • The functionality of using one or more user-defined types as the building block(s) of another class/struct
    • Use when the class exhibits the "HAS-A" relationship: A car HAS-A engine meaning an Engine class would need to be used in a Car class.
  • Polymorphism
    • The concept that allows objects of different classes to be treated as objects of a common base class.
    • It also allows methods to behave differently based on the object’s actual class.
    • This is typically achieved through method overriding (runtime polymorphism) and method overloading (compile-time polymorphism).

Sources:

  1. https://patrickkarsh.medium.com/7-principles-of-object-oriented-design-1ab0231d610a
  2. https://nexwebsites.com/blog/object-oriented-design-with-cpp/