DEV Community

Solid design principles part 1

In this short series I will try to briefly explain the solid design principle. If you are interested in a more detailed version you can read my blog entry about it. SOLID is an acronym and stands for the individual design principles that were first put into writing in this form by Robert C. Martin.

The goal of SOLID is the production of software, which tolerates modifications, is easily understandable and which forms a basis of the components, which are used in many software systems

SRP-Single Responsibility Principle

The Single Responsibility Principle (SRP) is probably the most misunderstood of the SOLID principles. According to Robert C. Martin, software developers tend to assume that each module should perform a single task. The principle of refactoring and splitting to the lowest level for functions with a large scope does exist, but this is not what is meant by SRP. In general, the description of SRP is:

There should never be more than one reason to modify a class.

However, since in most cases software is written for customers/stakeholders or users and the notion of classes is too specific at this point, the following statement by Robert C. Martin is recommended:

„A module should be responsible for one, and only one, actor“.
As an example, one could take a module that provides functions for different business areas. If there is a change in one business area such that the structure of the class needs to change, this could impact the part of the class that is needed by another part of the organization. This creates dependencies that can be blocking for software development. Thus, it would make sense to design classes and methods in such a way that only one actor is responsible for the requirements and adaptations.

With the SRP it concerns thus mainly functions and classes and their connection to actors, which create requirements.

⚡If you want to read more about that topic you can check out my blog
⭐ or follow me on twitter

Discussion (0)