SRP Everywhere

13
SRP Everywhere Make your application SOLID

Transcript of SRP Everywhere

Page 1: SRP Everywhere

SRP EverywhereMake your application SOLID

Page 2: SRP Everywhere

SRP

● What

● Why

● How

Page 3: SRP Everywhere
Page 5: SRP Everywhere

Why?

Page 6: SRP Everywhere

Some ‘good’ code examples

● Long methods● Long Controllers/Services● Long Models● Long Classes/Modules● Are you adding to ‘legacy’?

Page 7: SRP Everywhere

Pile-on-game!

Page 8: SRP Everywhere

http://blog.codeclimate.com/blog/2013/08/07/deciphering-ruby-code-metrics/

Page 9: SRP Everywhere
Page 10: SRP Everywhere

Class/Module

1. … should have one responsibility2. Responsibility is defined by business3. If there is more than one responsibility follow

step #1

Page 11: SRP Everywhere

Where else?

● Can methods follow SRP?● Can services follow SRP?● Can design follow SRP?

Page 12: SRP Everywhere

How to identify and work?

● Realistic and relevant naming● Think before ‘Pile-On’● Reassess business definition

Page 13: SRP Everywhere