Design principles
Like all the design patterns and principles in this chapter, the design principles we will review next are guidelines to help you write better, more maintainable, and more efficient code.
The common principles we will review in this section are shown in the following list:
- Don’t Repeat Yourself (DRY)
- Keep It Simple, Stupid (KISS)
- You Ain’t Gonna Need It (YAGNI)
- Law of Demeter (LoD) or the principle of least knowledge
- Composition over Inheritance
- Principle of least astonishment
DRY
The Don’t Repeat Yourself (DRY) principle is a fundamental concept in software development that emphasizes the importance of avoiding duplication in code. This principle encourages reducing the repetition of software patterns by abstracting out common functionality into a single place, thus enhancing the maintainability, readability, and scalability of code.
Here are some key takeaways about DRY:
-
...