1. Introducing SOLID Flashcards
What are the two principles of Pain-Driven Development?
- Avoid premature optimization
2. If the current design is painful to work with, use principles to guide the redesign
When should we apply the SOLID principles?
As your application grows and you continue to work with it, look for places where the app is painful to work with. That pain may exhibit itself as difficulty with testing or excess duplication, too much coupling, etc. When you feel that pain, see if any of the SOLID principles could be applied to alleviate the pain and improve the design.
What are the SOLID principles?
S — SRP — Single Responsibility Principle
O — OCP — Open Closed Principle
L — LSP — Liskov Substitution Principle
I — ISP — Interface Segregation Principle
D — DIP — Dependency Inversion Principle
What are the SOLID principles comprised of?
Five individual principles for writing better software, especially in object-oriented languages.
What can be said about applying SOLID principles upfront while solving problems in code?
Write your code using the simplest technique you know to get the problem solved. Don’t worry about SOLID initially. Trying to apply all of the SOLID principles upfront is a form of premature optimization of your app’s design. If the current design is painful to work with, use the principles to guide redesign.