SlideShare una empresa de Scribd logo
1 de 106
Descargar para leer sin conexión
Large scale Rails
applications
Florian Dutey
www.strikingly.com
We hire!
2007
1.2.3
Fat Models
Skinny Controllers
If it’s not a controller job,
leave it to the model.
If the screwdriver can’t solve it,
use the hammer.
Business complexity
Technical complexity
Solution = Complexity²
Rails doesn't scale!
NOT Rails!
Application
Http
Request
Response
Request Router Controller
ResponseView
Models
Request Router Controller
ResponseView
Models
Application
Principles
• Modularity
• Single Responsibility Object
• Plain Old Ruby Objects
• Inversion Of Control
• Stateless Objects
• Domain Specific Language
Modularity
• Controller
• Test
• Rake tasks
• Jobs
• Daemons
• …
Single Responsibility Principle
(SRP)
Not SRP
SRP
User
email
password
first_name
last_name
address_1
address_2
zip_code
city
country
User
email
password
User::Profile
user_id
first_name
last_name
User::Address
user_id
address_1
address_2
zip_code
city
country
Break things down
minimalist objects
“Make everything as simple as possible,
but not simpler.”
Albert Einstein
Plain Old Ruby Objects (PORO)
PORO
Not PORO
Inversion of controls
Separate what
and when
Why?
• Separate responsibilities
• Remove strong dependencies
• Easier to test
• Write highly abstract processes
Stateless objects
Stateless
Statefull
Why?
• No setup
• Predictable
Domain Specific Language
Router Controller
Domain
API language
Domain Specific Language
View API language
Break down
Request Router Controller
ResponseView
Application
?
??
??
Models
Services
Application
Forms Policies
Queries Adapters Models
Services Forms Policies
Queries Adapters Models
Application
Services (1)
Describe processes
Services (2)
Services (3)
Services (4)
Create != Signup
Services (5)
Services (6)
Services (7)
Services (8)
User::SignupService
Payment::SignupService
user/signup_service_spec
Payment::SignupService
payment/signup_service_spec
Services Forms Policies
Queries Adapters Models
Application
Forms (1)
Convert inputs in
Domain language
Forms (2)
USER
email
password
Forms (3)
Forms (4)
Forms (5)
Forms (6)
User
email
password
User::Profile
user_id
first_name
last_name
User
email
password
first_name
last_name
Forms (7)
accepts_nested_attributes_for
Forms (8)
Forms (9)
Forms (10)
Services Forms Policies
Queries Adapters Models
Application
Policies (1)
Describe permissions
Policies (2)
Policies (3)
Policies (4)
Services Forms Policies
Queries Adapters Models
Application
Queries (1)
Describe how to access data
Queries (2)
Queries (3)
Services Forms Policies
Queries Adapters Models
Application
Adapters (1)
Translate DSL into another
Adapters (2)
User
email
password
first_name
last_name
Recurly
Adapters (3)
Adapters (4)
It’s about languages
Adapters (5)
3rd party
API language
Client
Http request
Ruby method
Adapters (6)
Client
API Language
Adapter
DSL
Application
Adapters (7)
Adapters (8)
PaymentManager
RecurlyAdapter StripeAdapter
Benefits
• Easy to test (mock client responses)
• New provider => new adapter
• Easy to migrate
• Fake adapters for integration servers
Services Forms Policies
Queries Adapters Models
Application
Models (1)
Data
(& persistency)
Models (2)
If it doesn’t fit in models
…
Models (3)
Then it doesn’t fit in models!
Models (4)
Conclusion
It’s not a perfect solution,
just a guide
Pros
• Easier to browse and discover
• More flexible
• Easier to test
• Easier to debug
• Agnostic (from ActiveRecord)
after_commit
Cons
• Harder to design
• More time on code architecture
• Write more code, more tests
• Write integration tests (IOC)
Small apps
Soft transition
• Code convention
• Focus on data and API
• Express everything in DSL
• Write adapters early
• Drop assets pipeline
• Split FE / BE in different projects
Big apps
More tips
• If it doesn’t fit anywhere, think twice
• If it still doesn’t fit anywhere, you need a new layer
• Check what Java / React community does
Rails
is a fantastic prototyping tool!
Rails
is NOT an application framework
Rails
is a fantastic web framework!
Thank you!
Q & A

Más contenido relacionado

La actualidad más candente

Signal r azurepresentation
Signal r azurepresentationSignal r azurepresentation
Signal r azurepresentation
Justin Wendlandt
 
Orleans – a “cloud native” runtime built for #azure
Orleans – a “cloud native” runtime built for #azureOrleans – a “cloud native” runtime built for #azure
Orleans – a “cloud native” runtime built for #azure
Brisebois
 

La actualidad más candente (20)

Signal r azurepresentation
Signal r azurepresentationSignal r azurepresentation
Signal r azurepresentation
 
Migrate PHP E-Commerce Site to Go
Migrate PHP E-Commerce Site to GoMigrate PHP E-Commerce Site to Go
Migrate PHP E-Commerce Site to Go
 
Angular4 kickstart
Angular4 kickstartAngular4 kickstart
Angular4 kickstart
 
TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
 
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA....NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
 
Orleans – a “cloud native” runtime built for #azure
Orleans – a “cloud native” runtime built for #azureOrleans – a “cloud native” runtime built for #azure
Orleans – a “cloud native” runtime built for #azure
 
C# 9 - What's the cool stuff? - BASTA! Spring 2021
C# 9 - What's the cool stuff? - BASTA! Spring 2021C# 9 - What's the cool stuff? - BASTA! Spring 2021
C# 9 - What's the cool stuff? - BASTA! Spring 2021
 
C# 8 and .NET Core 3
C# 8 and .NET Core 3C# 8 and .NET Core 3
C# 8 and .NET Core 3
 
Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming Go
 
Porting ASP.NET applications to Windows Azure
Porting ASP.NET applications to Windows AzurePorting ASP.NET applications to Windows Azure
Porting ASP.NET applications to Windows Azure
 
.NET Core 3.0 - What's new?
.NET Core 3.0 - What's new?.NET Core 3.0 - What's new?
.NET Core 3.0 - What's new?
 
Gemboys
GemboysGemboys
Gemboys
 
Webservices: The RESTful Approach
Webservices: The RESTful ApproachWebservices: The RESTful Approach
Webservices: The RESTful Approach
 
Fast Web Applications with Go
Fast Web Applications with Go Fast Web Applications with Go
Fast Web Applications with Go
 
Unit Testing in JavaScript
Unit Testing in JavaScriptUnit Testing in JavaScript
Unit Testing in JavaScript
 
Ohio Devfest - Visual Analysis with GCP
Ohio Devfest - Visual Analysis with GCPOhio Devfest - Visual Analysis with GCP
Ohio Devfest - Visual Analysis with GCP
 
Async streams
Async streamsAsync streams
Async streams
 
Entity Framework Core 1.x/2.x Advanced
Entity Framework Core 1.x/2.x AdvancedEntity Framework Core 1.x/2.x Advanced
Entity Framework Core 1.x/2.x Advanced
 
Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)Relay: Seamless Syncing for React (VanJS)
Relay: Seamless Syncing for React (VanJS)
 

Similar a RubyConf Taiwan 2016 - Large scale Rails applications

Similar a RubyConf Taiwan 2016 - Large scale Rails applications (20)

21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
21o. RubyFloripa - Maintaining legacy Rails app and introducing Elixir
 
Phoenix for Rubyists
Phoenix for RubyistsPhoenix for Rubyists
Phoenix for Rubyists
 
2010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week12010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week1
 
Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular js
 
Api chaining(tm)
Api chaining(tm)Api chaining(tm)
Api chaining(tm)
 
Domain oriented development
Domain oriented developmentDomain oriented development
Domain oriented development
 
Testing for Logic App Solutions | Integration Monday
Testing for Logic App Solutions | Integration MondayTesting for Logic App Solutions | Integration Monday
Testing for Logic App Solutions | Integration Monday
 
Oleksandr Khotemskyi - Serverless architecture and how to apply it in Automa...
Oleksandr Khotemskyi  - Serverless architecture and how to apply it in Automa...Oleksandr Khotemskyi  - Serverless architecture and how to apply it in Automa...
Oleksandr Khotemskyi - Serverless architecture and how to apply it in Automa...
 
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
 
Client Technical Analysis of Legacy Software and Future Replacement
Client Technical Analysis of Legacy Software and Future ReplacementClient Technical Analysis of Legacy Software and Future Replacement
Client Technical Analysis of Legacy Software and Future Replacement
 
Device fragmentation vs clean code
Device fragmentation vs clean codeDevice fragmentation vs clean code
Device fragmentation vs clean code
 
Scala io2013 : Our journey from UML/MDD to Scala macros
Scala io2013 : Our journey from UML/MDD to Scala macrosScala io2013 : Our journey from UML/MDD to Scala macros
Scala io2013 : Our journey from UML/MDD to Scala macros
 
Software Design
Software DesignSoftware Design
Software Design
 
REST and REST-fulness
REST and REST-fulnessREST and REST-fulness
REST and REST-fulness
 
JDD2014: REST API versioning practice: from header to model - Łukasz Wierzbicki
JDD2014: REST API versioning practice: from header to model - Łukasz WierzbickiJDD2014: REST API versioning practice: from header to model - Łukasz Wierzbicki
JDD2014: REST API versioning practice: from header to model - Łukasz Wierzbicki
 
From ddd to DDD : My journey from data-driven development to Domain-Driven De...
From ddd to DDD : My journey from data-driven development to Domain-Driven De...From ddd to DDD : My journey from data-driven development to Domain-Driven De...
From ddd to DDD : My journey from data-driven development to Domain-Driven De...
 
Алексей Веркеенко "Symfony2 & REST API"
Алексей Веркеенко "Symfony2 & REST API" Алексей Веркеенко "Symfony2 & REST API"
Алексей Веркеенко "Symfony2 & REST API"
 
Functional solid
Functional solidFunctional solid
Functional solid
 
APIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidadAPIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidad
 
SGCE 2015 REST APIs
SGCE 2015 REST APIsSGCE 2015 REST APIs
SGCE 2015 REST APIs
 

Último

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 

RubyConf Taiwan 2016 - Large scale Rails applications