Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Off the Rails: Patterns for fixing fat models, ...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Alexander Clark
April 23, 2019
Technology
390
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
Transcript
40 slides
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?
More Decks by Alexander Clark
See All by Alexander Clark
Docker: What It Is and Why You Should Care
alexanderclark
0
420
Building with Rack
alexanderclark
2
410
Other Decks in Technology
See All in Technology
個人ASを取得して、自宅Kubernetes上のVMをグローバルIPで公開した話
munenick
0
230
自動計装なしでECSサービスをApplication Signalsに載せるまで
ota1022
2
470
Re:ゼロから始めるシェアハウスのペットな鯖
silmin_
0
270
[関西Kaggler会 20261113] 続・コミュニティコンペのススメ
nejumi
0
200
お風呂場をサーバルームにしよう
yusuke427
0
400
業務の傍らで進める改善ループエンジニアリング
bengo4com
1
240
Amazon Bedrock AgentCore の基礎とセキュリティ・ガバナンス
ren8k
0
270
そのイメージ、どのCIが作った? Artifact Attestationsで来歴を固定する / Which CI system created that image? Pinning provenance with Artifact Attestations
chmikata
0
270
Kiro Enterprise Management: 管理者が 1 か所で決め、全員の Kiro に届ける
inariku
PRO
0
100
新規事業開発でのAWS活用成功談&失敗談! 〜新規事業開発を専門に行うRelicならではのAWS活用〜
amixedcolor
1
140
Terraform 0 to 100:100個以上のリポジトリを常に最新にし続けるための自動化
sue445
3
1.4k
現場に渡し、構造で守る AI エージェントを活用したセルフサーブのデータ基盤の運用
legalontechnologies
PRO
0
110
Featured
See All Featured
Designing Powerful Visuals for Engaging Learning
tmiket
1
660
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
820
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
48k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
2
560
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
850
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
530
How to Ace a Technical Interview
jacobian
280
24k
Prompt Engineering for Job Search
mfonobong
0
610