Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Off the Rails: Patterns for fixing fat models, out-of-controllers, and other Rails problems
Alexander Clark
April 23, 2019
Technology
0
120
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
110
Building with Rack
alexanderclark
2
120
Other Decks in Technology
See All in Technology
開発者のための GitHub Organization の安全な運用と 継続的なモニタリング
flatt_security
3
3.9k
Stripe Search APIを利用した、LINEとStripeの顧客情報連携/line-dc-202205
stripehideokamoto
0
130
1年間のポストモーテム運用とそこから生まれたツール sre-advisor / SRE NEXT 2022
fujiwara3
6
3.5k
一人から始めるプロダクトSRE / How to start SRE in a product team, all by yourself
vtryo
4
2.9k
Graph API について
miyakemito
0
290
信頼性の階層の一段目を積み上げる/Monitoring Dashboard
shonansurvivors
0
180
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
0
600
LIFF Deep Dive 2022
line_developers
PRO
1
610
E2E自動テスト導入・運用をめぐる先入観と実際に起きたこと / Preconceptions and What Happened with E2E Testing
ak1210
5
1.3k
Oracle Cloud Infrastructure:2022年5月度サービス・アップデート
oracle4engineer
PRO
0
130
SRE の歩き方・進め方 / sre-walk-through-procedure
rrreeeyyy
0
500
[SRE NEXT 2022]メルカリグループにおけるSREs
srenext
0
400
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
319
19k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
181
15k
Web Components: a chance to create the future
zenorocha
303
40k
Typedesign – Prime Four
hannesfritz
33
1.3k
A Modern Web Designer's Workflow
chriscoyier
689
180k
Making the Leap to Tech Lead
cromwellryan
113
6.9k
Building an army of robots
kneath
299
40k
The Cult of Friendly URLs
andyhume
68
4.7k
Adopting Sorbet at Scale
ufuk
63
7.5k
Bash Introduction
62gerente
596
210k
Thoughts on Productivity
jonyablonski
43
2.2k
WebSockets: Embracing the real-time Web
robhawkes
57
5k
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?