Open/Closed Principle

Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.

  • Your classes should be open for extension
  • But closed for modification
  • You should be able to extend a classes behavior, without modifying it.
  • Use private variables with getters and setters – ONLY when you need them.
  • Use abstract base classes

Leave a Reply