Five principles for building software that is easy to understand, extend, and maintain. They reduce coupling, increase cohesion, and make code testable.
| SRP | One reason to change | "This class handles X and Y and Z" | | OCP | Add, don't modify | Growing if/else or switch chains for types | | LSP | Subtypes are substitutable | Type-checking or special-casing in calling code | | ISP | Small, focused interfaces | Empty method implementations or throw new Error("Not implemented") |
| DIP | Depend on abstractions | new ConcreteClass() inside business logic |
Wenden Sie SOLID-Prinzipien an, um flexiblen, wartbaren und testbaren Code zu schreiben. Wird beim Entwerfen von Klassen, Schnittstellen und Modulgrenzen verwendet. Deckt Single ab Verantwortung, Offen/Geschlossen, Liskov-Substitution, Schnittstellentrennung und Abhängigkeitsinversion mit praktischen TypeScript-Beispielen und Erkennungsheuristiken. Quelle: fellipeutaka/leon.