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
350
0
Share
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
370
Building with Rack
alexanderclark
2
370
Other Decks in Technology
See All in Technology
Rapid Start: Faster Internet Connections, with Ruby's Help
kazuho
2
920
Route 53 Global Resolver で高額課金発生!
otanikohei2023
0
130
AI時代 に増える データ活用先
takahal
0
340
Cortex Codeのコスト見積ヒントご紹介
yokatsuki
0
130
No Types Needed, Just Callable Method Check
dak2
1
2.4k
生成AIが変える SaaS の競争原理と弁護士ドットコムのプロダクト戦略
bengo4com
1
2.9k
「責任あるAIエージェント」こそ自社で開発しよう!
minorun365
10
2.6k
Forget technical debt
ufried
0
100
20年前の「OSS革命」に学ぶ AI時代の生存戦略
samakada
0
500
基盤を育てる 外部SaaS連携の運用
gamonges_dresscode
1
120
【技術書典20】OpenFOAM(自宅で深める流体解析)流れと熱移動(2)
kamakiri1225
0
330
Microsoft 365 / Microsoft 365 Copilot : 自分の状態を確認する「ラベル」について
taichinakamura
0
410
Featured
See All Featured
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
170
Building a Scalable Design System with Sketch
lauravandoore
463
34k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
450
Building an army of robots
kneath
306
46k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
130
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
780
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.4k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
200
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
200
Balancing Empowerment & Direction
lara
6
1.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
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?