↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Learn the SOLID principles for Object Oriented Programming

The page introduces object oriented programming as a way to group data and behavior into objects, then shows how classes define those objects and how multiple instances can share the same blueprint. It then uses simple C# examples to present the five SOLID principles as guidance for writing maintainable code.

Reading notes
#

  • OOP groups related code into objects, and classes serve as blueprints for those objects.
  • A class can be instantiated more than once, with each object holding its own values.
  • A “God” class collects unrelated behavior in one place and makes code harder to read and keep stable.
  • The single responsibility principle says a class should have one responsibility, so database-saving logic should move out of Person and into another class.
  • The open/closed principle says objects should be open for extension and closed for modification.
  • In the salary example, adding a new Person type should not require changing SalaryCalculator.
  • The Liskov substitution principle says subclasses should be usable in place of the base class without breaking expected behavior.
  • The interface segregation principle says clients should not be forced to implement methods they do not use, so smaller interfaces are preferred over a large CRUD interface.
  • The dependency inversion principle says classes should depend on interfaces instead of concrete classes, which loosens coupling between presentation, logic, and repository layers.
  • The conclusion presents SOLID as five principles for more maintainable object oriented code.