Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
3
280
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
Tweet
Share
More Decks by Andrey Savchenko
See All by Andrey Savchenko
Building web-API without Rails, registration or sms
ptico
3
890
The big, the small and the Redis
ptico
1
230
Zen TDD
ptico
2
190
The Application: An Unexpected Journey
ptico
1
290
How to f*ck up the refactoring
ptico
11
450
Practical SOLID with Rails
ptico
5
610
Redis - little helper for big applications (rus)
ptico
3
160
Other Decks in Programming
See All in Programming
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
150
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
160
開発に寄りそう自動テストの実現
goyoki
2
1.4k
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
160
生成AI時代を勝ち抜くエンジニア組織マネジメント
coconala_engineer
0
2.3k
Go コードベースの構成と AI コンテキスト定義
andpad
0
140
メルカリのリーダビリティチームが取り組む、AI時代のスケーラブルな品質文化
cloverrose
2
370
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
11
3.8k
Vibe codingでおすすめの言語と開発手法
uyuki234
0
110
Denoのセキュリティに関する仕組みの紹介 (toranoana.deno #23)
uki00a
0
160
公共交通オープンデータ × モバイルUX 複雑な運行情報を 『直感』に変換する技術
tinykitten
PRO
0
160
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
7
2.3k
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.4k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
90
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
510
Unsuck your backbone
ammeep
671
58k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.7k
Marketing to machines
jonoalderson
1
4.3k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
340
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
34
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
30
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Tell your own story through comics
letsgokoyo
0
760
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