Single Responsibility Principle (SRP)

Definition - What does Single Responsibility Principle (SRP) mean?

The single responsibility principle (SRP) is part of the “SOLID” acronym for programming principles developed by Robert C. Martin. It relates to each object in a codebase having a single specific function.

Techopedia explains Single Responsibility Principle (SRP)

SOLID principles include the single responsibility principle, as well as four other principles that rely on the SOLID acronym: open-closed, Liskov substitution, interface segregation and dependency inversion.

As part of this set, which is meant to simplify code development and extension and help with updates and changes, the single responsibility principle indicates a single function per class and helps with making code modular to prevent interdependencies. Classes and elements that have only one responsibility are easier to explain and easier to understand within a codebase environment. That makes the single function responsibility as part of the SOLID acronym a key way to optimize object-oriented programming.

Share this:

Recommended Resources