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
The scary fairy tale about MVC or How to stop w...
Search
Andrey Savchenko
May 31, 2013
Programming
280
3
Share
The scary fairy tale about MVC or How to stop worrying and start to write ruby code
Hotcode conference, 5 May 2013
Andrey Savchenko
May 31, 2013
More Decks by Andrey Savchenko
See All by Andrey Savchenko
Building web-API without Rails, registration or sms
ptico
3
910
The big, the small and the Redis
ptico
1
240
Zen TDD
ptico
2
200
The Application: An Unexpected Journey
ptico
1
310
How to f*ck up the refactoring
ptico
11
460
Practical SOLID with Rails
ptico
5
620
Redis - little helper for big applications (rus)
ptico
3
170
Other Decks in Programming
See All in Programming
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
220
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
310
おれのAgentic Coding 2026/03
tsukasagr
1
120
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
380
Kubernetesでセルフホストが簡単なNewSQLを求めて / Seeking a NewSQL Database That's Simple to Self-Host on Kubernetes
nnaka2992
0
190
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
1.2k
Goの型安全性で実現する複数プロダクトの権限管理
ishikawa_pro
2
1.4k
Migration to Signals, Signal Forms, Resource API, and NgRx Signal Store @Angular Days 03/2026 Munich
manfredsteyer
PRO
0
200
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
3
2.6k
PHPで TLSのプロトコルを実装してみる
higaki_program
0
610
Feature Toggle は捨てやすく使おう
gennei
0
390
Everything Claude Code OSS詳細 — 5層構造の中身と導入方法
targe
0
160
Featured
See All Featured
A Soul's Torment
seathinner
5
2.6k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Odyssey Design
rkendrick25
PRO
2
560
Designing for Timeless Needs
cassininazir
0
180
Building AI with AI
inesmontani
PRO
1
840
A better future with KSS
kneath
240
18k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
120
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
How STYLIGHT went responsive
nonsquared
100
6k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
Transcript
The scary fairy tale about MVC How to stop worrying
and start to write ruby code or
Andrey Savchenko @ptico @ptico_eng Aejis
Cast • Little Red Riding Hood - developer • Grandmother
- customers • The map - MVC • Compass - Rails And others…
nce upon a time, a little girl goes trough the
scary wood to deliver pies to her grandmother. O
here she met the Damn Horrible Human nicknamed «The Wolf»
T
here you are going, little girl? he asked. I’m going
to deliver pies to my grandma – she answered. W –
have a present for you – wolf said. Take this
map and this compass: it works very well for me. I
None
he girl took gifts and moved on. And have lost
in the wood. Because the compass was point to the wolf’s grandmother and map defines the ways not applicable for little girls. T
THE END
Moral: the tools which works for other person may doesn’t
work for you
MVC is a good example
What’s wrong with MVC?
It has only three letters MVC
One of them superfluous MVC
Application should know nothing about representation
Another one means a little bit more than nothing MVC
The controller should delegate the work that needs to be
done to other objects; it coordinates or controls the activity. It should not do much work itself. GRASP controller definition
So, what’s left?
The model M
M
M
M
None
Please, rise your hand if you have this kind of
models
So, this is a moment when we should start writing
the Ruby code
What does it mean?
Lets take a look at our daily gems
carrierwave
state_machine
resque
Ok, i catch the idea, lets start!
Wait a minute - we need some weapons
Metrics
Metrics • WPM - WTFs per minute
Metrics • WPM - WTFs per minute • SLOC/M -
Source lines of code per method
Metrics • WPM - WTFs per minute • SLOC/M -
Source lines of code per method • SLOC/C - Source lines of code per class
Overall complexity ((AVG(SLOC/M) + SLOC/C)^WPM)/100
Overall complexity If you have > 10 – i have
a bad news for you
Principles • SOLID
Principles • SOLID • YAGNI
Principles • SOLID • YAGNI • KISS
Secret weapon: Testability
The simpler your objects to test - the easier they
can be changed and reused
The more complex your objects is - the harder to
test them
Got it! What about strategy?
Strategies:
Use-case strategy
Use-case strategy • Doesn’t work with Rails • Requires to
build your own stack • But once you build this – its bullet-proof
Onion strategy
None
Onion strategy • Do work with Rails • Layer can
be just Plain Old Ruby Object • Layers is hard to naming
Onion strategy Model Controller View
Onion strategy Model Controller View Presenter
Onion strategy Model Controller View Presenter Form object
Onion strategy Model Controller View Presenter Form object Repository
Onion strategy Model Controller View Presenter Form object Repository Service
Onion strategy Model Controller View Presenter Form object Repository Service
Validator
Attribution: http://www.flickr.com/photos/42255449@N00/7177978063/ http://www.flickr.com/photos/normanbleventhalmapcenter/2674605704/ Thank you!
Questions? Andrey Savchenko Aejis* * we are hiring** ** if
you understand the problem described in talk