SRP Everywhere
Make your application SOLID
SRP
● What
● Why
● How
Definition
Long
In object-oriented programming, the single responsibility principle states that every class should
have responsibility over a single part of the functionality provided by the software, and that
responsibility should be entirely encapsulated by the class. All its services should be narrowly aligned
with that responsibility.
Short
… a responsibility is a reason to change...
Why?
Some ‘good’ code examples
● Long methods
● Long Controllers/Services
● Long Models
● Long Classes/Modules
● Are you adding to ‘legacy’?
Pile-on-game!
http://blog.codeclimate.com/blog/2013/08/07/deciphering-ruby-code-metrics/
Class/Module
1. … should have one responsibility
2. Responsibility is defined by business
3. If there is more than one responsibility follow
step #1
Where else?
● Can methods follow SRP?
● Can services follow SRP?
● Can design follow SRP?
How to identify and work?
● Realistic and relevant naming
● Think before ‘Pile-On’
● Reassess business definition
SRP Everywhere

SRP Everywhere