Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Off the Rails: Patterns for fixing fat models, out-of-controllers, and other Rails problems
Alexander Clark
April 23, 2019
Technology
0
160
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
160
Building with Rack
alexanderclark
2
150
Other Decks in Technology
See All in Technology
データベースの発表には RDBMS 以外もありますよ
maroon1st
0
240
AWS re:Invent 2022で発表された新機能を試してみた ~Cloud OperationとSecurity~ / New Cloud Operation and Security Features Announced at AWS reInvent 2022
yuj1osm
1
220
マイクロサービス宣言から8年 振り返りとこれから / Eight Years After the Microservices Declaration A Look Back and A Look Ahead
eisuke
2
170
NGINXENG JP#2 - 4-NGINX-エンジニアリング勉強会
hiropo20
0
120
都市ARの作り方 PLATEAU ✖︎ Geospatial API
41h0_shiho
0
250
初めてのデータ移行プロジェクトから得た学び
tjmtmmnk
0
400
OpenShiftクラスターのアップグレード自動化への挑戦! / OpenShift Cluster Upgrade Automation
skitamura7446
0
200
230125 モニターマウントLT ITガジェット翁(Ryu.Cyber)さん
comucal
PRO
0
4.8k
CES_2023_FleetWise_demo.pdf
sparkgene
0
120
re:Invent発表のサービスを取り入れて加速する弥生のSecurity&Governance / accelerating YAYOI's Security and Governance with services announced at reinvent
yayoi_dd
0
150
書籍を書きました。 そう、VS Codeで。
takumanakagame
4
4.6k
03_ユーザビリティテスト
kouzoukaikaku
0
630
Featured
See All Featured
A better future with KSS
kneath
230
16k
Optimizing for Happiness
mojombo
365
64k
Agile that works and the tools we love
rasmusluckow
320
20k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
224
50k
jQuery: Nuts, Bolts and Bling
dougneiner
57
6.6k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
239
19k
Imperfection Machines: The Place of Print at Facebook
scottboms
254
12k
Large-scale JavaScript Application Architecture
addyosmani
499
110k
Why You Should Never Use an ORM
jnunemaker
PRO
49
7.9k
Typedesign – Prime Four
hannesfritz
34
1.5k
Teambox: Starting and Learning
jrom
124
7.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
152
13k
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?