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
250
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
260
Building with Rack
alexanderclark
2
270
Other Decks in Technology
See All in Technology
サービス開発を前に進めるために 新米リードエンジニアが 取り組んだこと / Steps Taken by a Novice Lead Engineer to Advance Service Development
nologyance
0
180
DevIO2024_レガシー運用からの脱却 -クラウド活用の実践事例とベストプラクティス-
jun2882
0
210
ここがすごいよ! AWS Systems Manager!
saichan11
0
1.8k
AOAI Dev Day - Opening Session
yoshidashingo
2
470
Flutter研修【MIXI 24新卒技術研修】
mixi_engineers
PRO
0
160
What is DRE? - Road to SRE NEXT@広島
chanyou0311
3
630
MySQLのロックの種類とその競合
yoku0825
6
1.6k
スタートアップにおける組織設計とスクラムの長期戦略 / Scrum Fest Kanazawa 2024
yoshikiiida
13
3.6k
AWS IAMのアンチパターン/AWSが考える最低権限実現へのアプローチ概略(JAWS-UG朝会#59資料改修20分版)
htan
0
330
JBUG岡山 #6 WordCamp男木島の チームビルディング
takeshifurusato
0
150
AWSサービスメニュー開発をしていてAWSを好きだ!と感じた瞬間
toru_kubota
0
130
ABEMAにおけるLLMを用いたコンテンツベース推薦システム導入と効果検証
cyberagentdevelopers
PRO
1
750
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
12
3.8k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
19k
Into the Great Unknown - MozCon
thekraken
20
1.3k
Six Lessons from altMBA
skipperchong
24
3.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
26
1.6k
Being A Developer After 40
akosma
72
580k
How STYLIGHT went responsive
nonsquared
93
5k
Making Projects Easy
brettharned
111
5.7k
How GitHub Uses GitHub to Build GitHub
holman
471
290k
Build your cross-platform service in a week with App Engine
jlugia
227
17k
How to Think Like a Performance Engineer
csswizardry
4
590
Fantastic passwords and where to find them - at NoRuKo
philnash
42
2.7k
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?