Code Code: Class Design

Code Code: Class Design

2020, Aug 12    

Class Design

  • Single Responsiblity Principle (SRP)

    There should never be more than one reason for a class/module to change. more..

  • Open Closed Principle (OCP)

    Software entities… should be open for extension, but closed for modification. more..

  • Liskov Substitution Principle (LSP)

    Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it. more..

  • Dependency Inversion Principle (DIP)

    Software entities should be dependent on abstractions than concrete implementations. more..

  • Interface Segregation Principle (ISP)

    Clients should not be forced to depend upon interfaces that they do not use. more..

  • Classes should be small

    Smaller classes are easier to grasp. Classes should be smaller than 100 lines of code.

  • Do stuff or know others but not both

    Classes should either do stuff (algorithm, read data, write data, …) or orchestrate other classes. This reduces coupling and simplifies testing