Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
The scary fairy tale about MVC or How to stop w...
Search
Andrey Savchenko
May 31, 2013
Programming
320
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
Transcript
60 slides
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
More Decks by Andrey Savchenko
See All by Andrey Savchenko
Building web-API without Rails, registration or sms
ptico
3
940
The big, the small and the Redis
ptico
1
280
Zen TDD
ptico
2
230
The Application: An Unexpected Journey
ptico
1
340
How to f*ck up the refactoring
ptico
11
490
Practical SOLID with Rails
ptico
5
650
Redis - little helper for big applications (rus)
ptico
3
200
Other Decks in Programming
See All in Programming
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
230
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
SODA - FACT BOOK(EN)
sodainc
1
270
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
200
RaspberryPi 5で軽くはじめるk3sとtailscaleを用いたホームサーバー構築 (1)
nasum
0
420
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
250
作れるエンジニアから、価値を届けるエンジニアへ
ryunakayama
1
320
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
3
630
AIコーディング時代のKotest ユニットテストから APIレベルの仕様固定化テストへ
ooga04
0
310
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
190
エラーチャンネルのボールを拾い続けて鍛えるエンジニアの地力 / phpcon-niigata2026
meihei3
1
480
読みやすい!と評判(?)の発表の準備にかける私のこだわり
shoheimitani
0
110
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
1
250
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
2k
Claude Code のすすめ
schroneko
67
230k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
640
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
540
Believing is Seeing
oripsolob
1
290
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
290
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
GraphQLとの向き合い方2022年版
quramy
50
15k
Designing Powerful Visuals for Engaging Learning
tmiket
1
660
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
580