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
0
280
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
290
Building with Rack
alexanderclark
2
300
Other Decks in Technology
See All in Technology
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
460
隣接領域をBeyondするFinatextのエンジニア組織設計 / beyond-engineering-areas
stajima
1
270
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
350
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
Terraform未経験の御様に対してどの ように導⼊を進めていったか
tkikuchi
2
420
SSMRunbook作成の勘所_20241120
koichiotomo
1
100
複雑なState管理からの脱却
sansantech
PRO
1
130
CysharpのOSS群から見るModern C#の現在地
neuecc
1
3k
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
3
520
地理情報データをデータベースに格納しよう~ GPUを活用した爆速データベース PG-Stromの紹介 ~
sakaik
1
150
Microsoft MVPになる前、なってから/Fukuoka_Tech_Women_Community_1_baba
nina01
0
190
B2B SaaS × AI機能開発 〜テナント分離のパターン解説〜 / B2B SaaS x AI function development - Explanation of tenant separation pattern
oztick139
2
210
Featured
See All Featured
Teambox: Starting and Learning
jrom
133
8.8k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
A Philosophy of Restraint
colly
203
16k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
The World Runs on Bad Software
bkeepers
PRO
65
11k
4 Signs Your Business is Dying
shpigford
180
21k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Side Projects
sachag
452
42k
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?