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, out-of-controllers, and other Rails problems
Search
Alexander Clark
April 23, 2019
Technology
0
220
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
240
Building with Rack
alexanderclark
2
250
Other Decks in Technology
See All in Technology
DevOpsDays History and my DevOps story
kawaguti
PRO
9
2.4k
Google Cloud の AI を支える裏側のインフラを垣間見る!
maroon1st
0
330
Oracle Cloud Infrastructure:2024年4月度サービス・アップデート
oracle4engineer
PRO
1
180
検証を通して見えてきたTiDBの性能特性
lycorptech_jp
PRO
6
3.7k
コンテナセキュリティの基本と脅威への対策
kyohmizu
3
750
Azure Container Apps + Bicep 〜 こんな感じで運用しています
kaz29
2
430
コードを書く隙間を見つけて生きていく技術/Findy 思考の現在地
fujiwara3
27
5.8k
現代CSSフレームワークの内部実装とその仕組み
poteboy
8
3.5k
複雑な構成要素を持つUIとの向き合い方 〜新・支出グラフでの実例〜 / B43 TECH TALK
nakamuuu
0
140
KubeConにproposalを送りたい人へのアドバイス
sat
PRO
3
220
[PlatformCon 24] Platform Orchestrators: The Missing Middle of Internal Developer Platforms?
danielbryantuk
1
830
20240416_devopsdaystokyo
kzkmaeda
1
210
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
19
1.7k
Practical Orchestrator
shlominoach
182
9.7k
How STYLIGHT went responsive
nonsquared
92
4.8k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
What's new in Ruby 2.0
geeforr
337
31k
Optimising Largest Contentful Paint
csswizardry
8
2.3k
In The Pink: A Labor of Love
frogandcode
138
21k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
120
39k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
20
1.9k
RailsConf 2023
tenderlove
3
540
Understanding Cognitive Biases in Performance Measurement
bluesmoon
7
990
Why Our Code Smells
bkeepers
PRO
331
56k
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?