SRP Everywhere

Post on 04-Aug-2015

182 views 1 download

Transcript of SRP Everywhere

SRP EverywhereMake your application SOLID

SRP

● What

● Why

● How

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 responsibility2. Responsibility is defined by business3. 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