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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Andrey Savchenko
May 31, 2013
Programming
300
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
920
The big, the small and the Redis
ptico
1
250
Zen TDD
ptico
2
210
The Application: An Unexpected Journey
ptico
1
320
How to f*ck up the refactoring
ptico
11
470
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
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
730
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
250
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
550
さぁV100、メモリをお食べ・・・
nilpe
0
150
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
590
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.4k
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
170
ふつうのFeature Flag実践入門
irof
8
4.1k
Claspは野良GASの夢をみるか
takter00
0
200
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
670
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
130
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
540
A Soul's Torment
seathinner
6
3k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Speed Design
sergeychernyshev
33
1.9k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
260
My Coaching Mixtape
mlcsv
0
150
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
We Are The Robots
honzajavorek
0
250
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
250
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
220
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