Let’s Extract a Class: The Single Responsibility Principle and Design Patterns
summary
Starts from a concrete signup flow that moves email confirmation and signup rules out of controllers and models into a UserSignup class, which reduces controller surface area, speeds tests and absorbs branching like admin skips. Shows form objects that create user plus waiver transactionally, policies for access rules, decorators for views, and a repository that eliminates N+1 by repository batching external breed lookups. Recommends ADRs and a proof of concept to introduce changes.
AI-written summary · about
chapters (12)
- 0:00Introduction to code design
- 1:01Standard Rails MVC patterns
- 2:23The limitations of thick models
- 5:32Extracting business logic
- 9:56Presenters and decorators
- 11:47Form objects
- 13:51Service objects and policies
- 15:48Query objects
- 16:44Value objects
- 18:47Repositories
- 22:05Architectural principles
- 24:00Leading team changes
related talks
46mBe pragmatic, be SOLID
32mRuby for Startups
25mFrom Concept to Code: Domain-Driven Design for .NET Business Applications
41mA design pattern goes to the supermarket
17mThe 5 developers’ principles that helped me as a new father
34mUser-driven Apps: Securely Build for Defined DBMS Users
32mRules, Laws, and Gentle Guidelines
27mYour TDD Treasure Map
