Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Off the Rails: Patterns for fixing fat models, ...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Alexander Clark
April 23, 2019
Technology
360
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Off the Rails: Patterns for fixing fat models, out-of-controllers, and other Rails problems
Alexander Clark
April 23, 2019
More Decks by Alexander Clark
See All by Alexander Clark
Docker: What It Is and Why You Should Care
alexanderclark
0
390
Building with Rack
alexanderclark
2
380
Other Decks in Technology
See All in Technology
AI工学特論: MLOps・継続的評価
asei
10
2.3k
SoccerMaster: A Vision Foundation Model for Soccer Understanding
kzykmyzw
0
180
どこまでAIに任せるか 〜確率論と決定論の境界決定〜
shukob
0
510
伝票作成AIエージェントを支える、LLMOpsとインフラの選択肢 / AICon2026_takeda
rakus_dev
0
270
そのドキュメント、自動化しませんか?
yuksew
1
430
なぜ、あなたのエージェントは言うことを聞かないのか
segavvy
1
450
MCPをつなげて作る組織横断のAIエージェント基盤
tsubakimoto_s
0
140
Alphaモジュール使っていいのかい!?いけないのかい!?どっちなんだいっ!?
watany
1
330
探索・可視化・自動化を一本化 Amazon Quickでデータ活用スピードを上げる方法
koheiyoshikawa
0
190
設計レビューとAIハーネスで向き合う AIが生み出した新しいボトルネックの対処法 / Design Reviews and AI Harnesses Against New Bottlenecks Created by AI
nstock
5
480
生成 AI 時代にいま一度「問い合わせ」について考えてみる
kazzpapa3
1
130
発表と総括 / Presentations and Summary
ks91
PRO
0
210
Featured
See All Featured
Done Done
chrislema
186
16k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Producing Creativity
orderedlist
PRO
348
40k
Writing Fast Ruby
sferik
630
63k
The Cult of Friendly URLs
andyhume
79
7k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Discover your Explorer Soul
emna__ayadi
2
1.2k
Why Our Code Smells
bkeepers
PRO
340
58k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
Design in an AI World
tapps
1
270
Being A Developer After 40
akosma
91
590k
Product Roadmaps are Hard
iamctodd
55
12k
Transcript
Off the Rails Patterns for fixing fat models, out-of-controllers, and
other Rails problems
What I’m about to tell you is wrong.
YMMV
MVC
View Controller Model
3 Tier Architecture
Business Logic Presentation Data
Business Logic Presentation Data
Business Logic Presentation Data View Controller Model
Business Logic Presentation Data View Controller Model
View Controller Model Business Logic Presentation Data
None
None
None
View Controller Model
Model Service View Controller
Business Logic Presentation Data
Business Logic Presentation Data
Business Logic Presentation Data Service
None
None
Controller Rule of Thumb A Controller May Contain: • Public
REST methods • Private before_action setters • Private strong params method
Models
Business Logic Presentation Data View Controller Model
Business Logic Presentation Data View Controller Model
Business Logic Presentation Data View Controller Model Repository
None
Business Logic Presentation Data View Controller Validator Model
None
None
None
None
–Sandi Metz “duplication is far cheaper than the wrong abstraction”
YAGNI
Bonus Tip
None
None
Thanks for Listening Alexander Clark atheclark alexander-clark.com alexander-clark
Further reading • https://codeclimate.com/blog/7-ways-to-decompose-fat- activerecord-models/ • Patterns of Enterprise Application
Architecture (Fowler) • Domain Driven Design (Evans) • All the Little Things (Metz) https://www.youtube.com/ watch?v=8bZh5LMaSmE • Ruby Object Mapper https://rom-rb.org/
Questions?