An effective software system design can be created by developers with the use of a set of rules known as software design principles.
The main software design principles are as follows:
SOLID is a common set of design principles used in object-oriented software development. SOLID consists of five essential design principles:
According to this concept, a class should have only one responsibility. There should only be one cause for a class to change. SRP compacts and neatens classes by assigning each one a single problem, task, or concern.
According to this approach, a class should be open for extensions but closed for modifications. The "closed" part of the rule indicates that after a class has been written and tested, the code should only be modified to fix bugs. The "open" part indicates that you should be able to expand an existing class to add new functionality.
According to this principle, derived classes must be able to replace any object for their base classes. In basic terms, objects from a parent class can be swapped by objects from its derived classes without affecting the code. To use this concept, the behavior of your classes takes precedence over their structure.
This concept states that customers in your class should not be compelled to rely on methods they do not use. Similar to the SRP, the ISP's purpose is to limit the side effects and frequency of required changes by dividing the code into distinct, independent components.
The Dependency Inversion Principle (DIP) in.NET states that high-level modules should be based on abstractions rather than real implementations. The concept encourages flexible and maintainable software design by separating high- and low-level modules. The Dependency Injection pattern incorporates this concept, allowing for flexible coupling and easy testing.
DRY stands for "Don't Repeat Yourself." According to this concept, any small bit of knowledge (code) can only occur once in the complete system. This allows us to design scalable, maintainable, and reusable code.
KISS stands for Keep It Simple, Stupid! This principle highlights that each tiny piece of software should be kept simple, with needless complexity eliminated. This allows us to write more maintainable code.
YAGNI stands for "You Ain't Gonna Need It." This concept emphasizes that you should always implement things when they are needed. Never implement things before they are needed.