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
260
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
270
Building with Rack
alexanderclark
2
280
Other Decks in Technology
See All in Technology
社内の学びの場・コミュニティ形成とエンジニア同士のリレーションシップ構築/devreljapan2024
nishiuma
3
260
スタッフエンジニアの道: The Staff Engineer’s Path
snoozer05
PRO
43
14k
Oracle Exadata Database Service(Dedicated Infrastructure):サービス概要のご紹介
oracle4engineer
PRO
0
9.5k
突撃! 隣のAmazon Bedrockユーザー 〜YouはどうしてAWSで?〜
minorun365
PRO
3
350
セキュリティ監視の内製化 効率とリスク
mixi_engineers
PRO
7
920
ビジネスとエンジニアリングを繋ぐプロダクトを中心とした組織づくりの実践
sansantech
PRO
1
180
不動産tech Product Night#2_AIことはじめ_GA橋本
takehikohashimoto
0
170
Swift Testingのconfirmationを コードリーディング/Dive into Swift Testing confirmation
laprasdrum
1
240
Google CloudのLLM活用の選択肢を広げるVertex AIのパートナーモデル
nayuts
0
120
Mocking in Rust Applications
taiki45
1
400
チームビルディングは"感性"で向き合おう / Team Building with Awareness
kohzas
0
140
Segment Anything Model 2
tenten0727
3
640
Featured
See All Featured
Optimizing for Happiness
mojombo
375
69k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
278
13k
Code Review Best Practice
trishagee
62
16k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
23
1.7k
Agile that works and the tools we love
rasmusluckow
327
20k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.4k
Gamification - CAS2011
davidbonilla
79
4.9k
Atom: Resistance is Futile
akmur
261
25k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
663
120k
Mobile First: as difficult as doing things right
swwweet
221
8.8k
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?