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
310
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
930
The big, the small and the Redis
ptico
1
260
Zen TDD
ptico
2
220
The Application: An Unexpected Journey
ptico
1
330
How to f*ck up the refactoring
ptico
11
480
Practical SOLID with Rails
ptico
5
640
Redis - little helper for big applications (rus)
ptico
3
180
Other Decks in Programming
See All in Programming
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
100
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
600
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
160
「AI時代、配布するPythonコードをどう守るか: 難読化の実験と判断軸」 #PyconJP2026
pkshadeck
PRO
2
180
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
120
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.5k
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
3
360
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.3k
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
55
36k
コンパウンドプロダクト開発のためのローカルプロセスマネージャー再発明 #layerxgo
izumin5210
0
660
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
0
250
AIエージェント時代のコードレビューを設計する
nogu66
6
2.6k
Featured
See All Featured
The Spectacular Lies of Maps
axbom
PRO
1
980
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
410
Game over? The fight for quality and originality in the time of robots
wayneb77
1
270
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.1k
Building AI with AI
inesmontani
PRO
1
1.2k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
200
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
480
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