What does SOLID stand for?
What is the Single Responsibility Principle?
There should NEVER be more than ONE reason for a class to change → ONE JOB
What are (3) indicators for the Single Responsibility Principle?
What is a class client?
A class using another class’s public funtions
How to follow the Single Responsibility Principle?
Division into multiple simple classes with…
What is the Open Closed Principle?
Classes should be open for extension but closed for modification.
→ Never modify a class in order to handle a new one
What are (2) indicators for the Open Closed Principle?
3. Switch-Case to check object type
How to follow the Open Closed Principle?
2. Interfaces
When is it okay to use switch-case?
In a Factory Pattern to ask “Who do you wanna be?”
Explain the Dependency Inversion Principle
Never depend on (call) a concrete class! Always depend on your own abstractions.
What are (2) indicators for the Dependency Inversion Principle?
2. Long chain of dependencies (coupling)
How to follow the Dependency Inversion Princliple?
What patterns use the Dependency Inversion Principle?
Explain the adapter pattern
Integration (use) of any class without your own Interface and without modifying the target class
Explain the template pattern
Seperation of algorithm and its implementations with inheritance
Explain the strategy pattern
Algorithm and Implementation depend on Abstraction (Interface and Composition)
Was is the Interface Segregation Principle?
Don’t force clients to depend upon interfaces they do not use.
→ No fat interfaces!
What is a client interface?
Public Function
→ Service proposed to other classes
What are (3) indicators for unterface segregation?
What is a fat interface?
One that has many public functions
How to follow interface segregation?
Split up interfaces so they are…
What general problem is described by abstraction inconsistency?
Bad functions and classes are everywhere!
→ abstraction naming and behaviour are inconsistent
What (3) can you do to avoid abstraction inconsistency?
Explain Liskov’s Substitution Principle in your own words!
A child class should have the same public behaviour as it’s parent. Thus it should be able to replace it at any time.