SlideShare a Scribd company logo
How (not) to get lost in bigger
Ruby On Rails project
More layers than only MVC
and maybe more mess
- Oliver Kriška - quatermain32@gmail.com
- first e-shop in 2015
- FRI UNIZA 2008 - 2011
- EUBA 2011-2011
- Kadetade 2009 - ...
- Ruby on Rails 2011
- BeeSafe 2013 - ...
- freelancing 2014
- ShopVox (SF - USA) 2014 - ...
Who am I?
fatality
fail
WIN
What is Ruby On Rails?
- 2004
- MVC framework
- Ruby language (1995)
- Optimize for programmer happiness
- Convention over Configuration
- Exalt beautiful code
- Value integrated systems (complete solution)
- Basecamp, GitHub, Shopify, Airbnb, Twitch, SoundCloud, Hulu, Zendesk, Square,
Highrise, Envato Marketplace (Themeforest, Photodune, ...)
by http://rubyonrails.org/doctrine
What is MVC?
- Design Pattern
- Architectural
Pattern
- Model
- View
- Controller
Browser Model
Controller
View
by Google Search
RoR vs MVC?Browser
DBController
Requests
Responses
View
Model
DB Queries
Create/Update
Read
Load Data
Response
Read
What is Shopvox?
- Complex
- Web-based
- Job management
- CRM
- Point of Sale (POS)
- For custom shop and print industry
ShopVOX vs MVC
Controller ModelView
Presenter Query
Service
Why so complicated?
- Fat model
- Fat controller
- Fat view
- Too much logic!!
- Creating Work Order
- ~350 lines
- Model?
- Controller?
- Service per action
- Index Jobs
- ~ 150 lines query
- JSON presenter - ~ 350 lines
- View?
- Presenter
What is Presenter?
- Move logic from html/json template to some class
- Nice & clean template
- Freedom of use
- Speed
- Decorators, Presenters, JSONPresenters(?)
What is Service?
- Move logic from Controllers and Models
- Dynamic validations
- Creating nested models
- Complex logic
- Indexing
- Backup data
- Counting
- Notifications
- Third Party APIs
- Generators (Transaction numbers, Colors, Keys)
What is Query?
- Move logic from Controllers
- Dynamic queries
- Filters/Conditions
- Ordering
- Restrictions
- Calculations
- Stats (pagination, summary)
- Speed
- Loading connected data
- Loading only necessary data
- Jobs query
- 27 parts
- Pos query
- 6 base classes
- 200 lines
- 50 parts

More Related Content

WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.

  • 1. How (not) to get lost in bigger Ruby On Rails project More layers than only MVC and maybe more mess
  • 2. - Oliver Kriška - quatermain32@gmail.com - first e-shop in 2015 - FRI UNIZA 2008 - 2011 - EUBA 2011-2011 - Kadetade 2009 - ... - Ruby on Rails 2011 - BeeSafe 2013 - ... - freelancing 2014 - ShopVox (SF - USA) 2014 - ... Who am I? fatality fail WIN
  • 3. What is Ruby On Rails? - 2004 - MVC framework - Ruby language (1995) - Optimize for programmer happiness - Convention over Configuration - Exalt beautiful code - Value integrated systems (complete solution) - Basecamp, GitHub, Shopify, Airbnb, Twitch, SoundCloud, Hulu, Zendesk, Square, Highrise, Envato Marketplace (Themeforest, Photodune, ...) by http://rubyonrails.org/doctrine
  • 4. What is MVC? - Design Pattern - Architectural Pattern - Model - View - Controller Browser Model Controller View by Google Search
  • 5. RoR vs MVC?Browser DBController Requests Responses View Model DB Queries Create/Update Read Load Data Response Read
  • 6. What is Shopvox? - Complex - Web-based - Job management - CRM - Point of Sale (POS) - For custom shop and print industry
  • 7. ShopVOX vs MVC Controller ModelView Presenter Query Service
  • 8. Why so complicated? - Fat model - Fat controller - Fat view - Too much logic!! - Creating Work Order - ~350 lines - Model? - Controller? - Service per action - Index Jobs - ~ 150 lines query - JSON presenter - ~ 350 lines - View? - Presenter
  • 9. What is Presenter? - Move logic from html/json template to some class - Nice & clean template - Freedom of use - Speed - Decorators, Presenters, JSONPresenters(?)
  • 10. What is Service? - Move logic from Controllers and Models - Dynamic validations - Creating nested models - Complex logic - Indexing - Backup data - Counting - Notifications - Third Party APIs - Generators (Transaction numbers, Colors, Keys)
  • 11. What is Query? - Move logic from Controllers - Dynamic queries - Filters/Conditions - Ordering - Restrictions - Calculations - Stats (pagination, summary) - Speed - Loading connected data - Loading only necessary data - Jobs query - 27 parts - Pos query - 6 base classes - 200 lines - 50 parts