Single Responsibility Principle (SRP)
The Single Responsibility Principle (SRP) is the concept that any single object in object-oriented programing (OOP) should be made for one specific function. SRP is part of SOLID programming principles put forth by Robert Martin. Traditionally, code that is in keeping with SRP has a single function per class.
SRP is intended to help make code modular with fewer difficulties arising from inter-dependencies. Making code more modular and packaged into functions helps make it more reusable and helps avoid time wasted recoding what has already been done. Adoption of SRP is supposed to help when updating code as there are fewer points of concern when a need is found to update a certain function.
Critics of SRP point out that the practice often results in numerous snippets of code tied together with too many microservices. However, it’s been noted that Martin has also recommended related functions need not be strictly isolated to be in keeping with SRP, saying, “Gather together the things that change for the same reasons. Separate those things that change for different reasons.”