Episode 12 – The Interface Segregation Principle

Clean Code

Episode 12

This episode talks about the Interface Segregation principle.

  • Interfaces
    • Example: A light switch
    • switch —>> Interface <|—- light
    • The interface is couple with the switch more than the light object. Should call switchable.
    • Interfaces have more to do with the class that use them then the class that implement them.
           /--- D1 <---\
B (v) <---|             |--- M
           \--- D2 <---/
  • The Interface Rant
    • Deadly diamond of death
    • M could either have one instance variable v or two coming from each D1 and D2.
  • Fat Classes
    • The main class multiple inheritance many interface classes. Isolate fat classes by isolated each client specific interfaces and deploy them separately and able to develop separately.
  • The ATM example
  • Physical Structure
    • Ensure you don’t depend on method that you don’t call, otherwise, unnecessary coupling.
  • Factory
  • Dynamics and Injection
    • Dependency Injection
    • Main should create the messenger instance, all of the interactors, and main should takes the interactors and pass them across the boundary to the application.
  • The Need to know
    • Don’t force the user to depend on thing that you need
  • References
Advertisements