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
Alexander Clark
April 23, 2019
Technology
0
290
Off the Rails: Patterns for fixing fat models, out-of-controllers, and other Rails problems
Alexander Clark
April 23, 2019
Tweet
Share
More Decks by Alexander Clark
See All by Alexander Clark
Docker: What It Is and Why You Should Care
alexanderclark
0
310
Building with Rack
alexanderclark
2
310
Other Decks in Technology
See All in Technology
ココナラのセキュリティ組織の体制・役割・今後目指す世界
coconala_engineer
0
220
Redshiftを中心としたAWSでのデータ基盤
mashiike
0
100
バクラクの組織とアーキテクチャ(要約)2025/01版
shkomine
13
3k
[JAWS-UG栃木]地方だからできたクラウドネイティブ事例大公開! / jawsug_tochigi_tachibana
biatunky
0
130
【Λ(らむだ)】アップデート機能振り返りΛ編 / PADjp20250127
lambda
0
120
Grafanaのvariables機能について
tiina
0
180
レイクハウスとはなんだったのか?
akuwano
15
2k
Fin-JAWS第38回reInvent2024_全金融系セッションをライトにまとめてみた
mhrtech
1
100
プロダクト観点で考えるデータ基盤の育成戦略 / Growth Strategy of Data Analytics Platforms from a Product Perspective
yamamotoyuta
0
210
日本語プログラミングとSpring Bootアプリケーション開発 #kanjava
yusuke
2
340
Agentic AI時代のプロダクトマネジメントことはじめ〜仮説検証編〜
masakazu178
3
390
NOSTR, réseau social et espace de liberté décentralisé
rlifchitz
0
130
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.2k
The Cult of Friendly URLs
andyhume
78
6.2k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
19k
Six Lessons from altMBA
skipperchong
27
3.6k
Unsuck your backbone
ammeep
669
57k
A Modern Web Designer's Workflow
chriscoyier
693
190k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Raft: Consensus for Rubyists
vanstee
137
6.7k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
380
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
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?