Single Responsibility
- Do one thing and do it well
- Lots of small methods and lots of small classes easier to maintain
- Need to balance granularity and maintainability
- Using factory is single place to create things
- Should only have one requirement to cause class to change
- Easier to find problems and identify what is responsible for error
Open-Closed Principle
- Be open for extension and closed for modification
- Once a class is done, It is done (only bug fixes can change all other changes create new classes)
- Make base classes generic and inherit from base classes for changes
- Polymorphic – Based on interfaces using API, Inheriting the interface and functionality.
Liskov Substitution Principle
- Derived classes can stand in for base classes
- Factory provides class that is needed for code
Interface Segregation Principle
- Make specific interfaces client specific
Dependency Inversion Principle
- Depend on Abstractions, Not Concrete Implementations
Focus on quality of code
- Don’t Repeat yourself
- Eliminate Technical Debt, Extract methods, Leave code cleaner than you found it
- Separation of concerns
- Think about code and what it is doing
- Structural, Behavioral, Procedural Patterns
- Program to an interface of classes using adapters
- Allows to use mock interfaces for testing
- Maps one thing to another
- Façade Makes code easier to read
- Decorator takes a base and decorates it
- Not setting values of Class decorating interfacing it recursively