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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Andrey Savchenko
May 31, 2013
Programming
290
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
210
The Application: An Unexpected Journey
ptico
1
320
How to f*ck up the refactoring
ptico
11
460
Practical SOLID with Rails
ptico
5
630
Redis - little helper for big applications (rus)
ptico
3
170
Other Decks in Programming
See All in Programming
【ディップ|26年新卒研修資料】TDD実装演習
dip_tech
PRO
0
190
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
460
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
260
From Formal Specification to Property Based Test
ohbarye
0
2.6k
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
520
Liberating Ruby's Parser from Lexer Hacks
ydah
2
2.7k
20260514_its_the_context_window_stupid.pdf
heita
0
1k
Agent Skills を社内で育てる仕組み作り
jackchuka
1
2k
空間オーディオの活用
objectiveaudio
0
150
Sans tests, vos agents ne sont pas fiables
nabondance
0
120
実用!Hono RPC2026
yodaka
2
320
AlarmKitで明後日起きれるアラームアプリを作る
trickart
0
140
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
41
2.5k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
Mind Mapping
helmedeiros
PRO
1
190
Color Theory Basics | Prateek | Gurzu
gurzu
0
310
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
230
A designer walks into a library…
pauljervisheath
211
24k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
310
Deep Space Network (abreviated)
tonyrice
0
140
Six Lessons from altMBA
skipperchong
29
4.2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
520
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