Object Oriented Design Principles Cheat Sheet

Photo by Ronan Furuta on Unsplash


My aim here is not to go into detail but create a cheatsheet to quickly review before interviews to serve as a reminder.

OOP Concepts

  • Abstraction (hide complexity — blackbox, show only essential details. interfaces, abstract classes)
  • Encapsulation (private fields, public getter/setter. code update in one place)
  • Inheritance
  • Polymorphism (method overloading, method overriding)

SOLID Principles

  • Single Responsibility
  • Open-Closed Principle (open for extension, closed for modification)
  • Liskov’s Substitution (Rabbit extends Animal. classes should be substitutable)
  • Interface Segregation (instead of a single interface, prefer multiple smaller interfaces)
  • Dependency Inversion (Decoupling. depend on abstractions, interfaces)

Design Patterns
(Creational — Structural — Behavioral)

Best examples can be found here:

  • Abstract Factory (factory of factories)
  • Builder (complex objects using smaller objects)
  • Prototype (cloning)
  • Singleton (single instance)
  • Bridge (decouple an abstraction from its implementation)
  • Composite (a class that contains group of its own objects)
  • Decorator (wrapper / no modifications on existing class, new functionality added)
  • Facade (hides complexity)
  • Flyweight (reduce weight of object creation, create if needed or reuse)
  • Proxy (a class represents functionality of another class — create a proxy class having original object)
  • Command (stock.buy returns BuyStock, stock.sell returns SellStock — both using Stock class)
  • Interpreter (language grammer, sql parsing)
  • Iterator (.next)
  • Mediator (communication between different classes)
  • Memento (restores to a previous state)
  • Observer (register, notify)
  • State (status, context)
  • Null Object (for do-nothing relationship, instead of returning null value)
  • Strategy (a class behavior or its algorithm can change at runtime)
  • Template (abstract class, method flow)
  • Visitor (execution algorithm of element can vary as and when visitor varies)
  • MVC



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nil Seri

Nil Seri

I would love to change the world, but they won’t give me the source code | coding 👩🏼‍💻 | coffee ☕️ | jazz 🎷 | anime 🐲 | books 📚 | drawing 🎨