SlideShare a Scribd company logo
1 of 35
Download to read offline
Beyond 
The Rails Way 
Andrzej Krzywda 
http://rails-refactoring.com
Why is Rails 
business-friendly? 
• Quick to produce a prototype 
• Prototypes are production-ready enough 
• Easy to add new features 
• Possible to turn a prototype into proper 
production app
Because of The Rails Way
Why is Rails not business-friendly? 
• Because of The Rails Way 
• Business loves the speed of adding new features 
• … but loves predictability even more 
• There’s no predictability with The Rails Way
The Rails Way 
• Scaffold-like code in controllers/views 
• ActiveRecord goes all the way up to the view 
• features implemented with external gems 
• external gems assume ActiveRecord in the views 
• all models connected to each other with associations 
• non-trivial things implemented with callbacks, filters, state-machine, STI, validations 
• some JS/Coffee on top of the server-rendered html 
• one monolith app 
• Convention over Configuration 
• Magic (relying on meta) 
• Don’t Repeat Yourself 
• “We’re 95% done with this app, can you help us finish it?”
When is The Rails Way 
good? 
• for business/coding people to prototype 
• for less-experienced developers 
• to quickly get a result 
• for geniuses 
• they will handle any code 
• mostly-CRUD 
• logic-less apps
When is The Rails Way bad? 
• advanced developers 
• complex business logic 
• long-living business processes (like order) 
• multiple teams 
• predictable speed of work
If not The Rails Way 
then what?
Beyond 
The Rails Way
The Next Way
The Next Way 
• service objects 
• repositories 
• form objects 
• adapters 
• domain objects 
• events
The Next Way is heavily 
influenced by DDD and classical 
OOP patterns
It’s not all or nothing
You can mix The Rails Way 
with The Next Way
Gradual changes
start with service objects
service objects are the 
gateway drug
Gradually reduce 
the Rails magic
Magic is bad
We’re software developers, 
not software magicians
Turn implicit into explicit.
Turn conventions 
into 
explicit code
Don’t Repeat Yourself 
We went too far with this rule.
Coupling is worse 
than 
code duplication
DRY examples 
• It’s OK to have different User classes for 
authentication, storage and for presentation 
• It’s OK to duplicate some code in controllers/services 
instead of relying on the controller filters
The Next Way is just one 
possible set of techniques
Other alternatives 
• DCI / Clean Ruby 
• CQRS 
• Event Sourcing 
• Ports & Adapters
Choose what’s best for your 
project
Experiments are OK 
(as long as you keep the app working)
Make safe changes
small steps
Your tests should be green 
all the time
Learn how to refactor 
without any fear.
Rails Refactoring recipes 
• Inline controller filters 
• Explicitly render views with locals 
• Extract render/redirect methods 
• Extract a SingleActionController class 
• Extract a routing constraint 
• Extract an adapter object 
• Extract a repository object 
• Extract a service object
Thanks! 
“Fearless Refactoring: Rails Controllers” 
http://rails-refactoring.com 
still on a discounted price! 
(1.0 available from December 1st)

More Related Content

What's hot

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)Igor Talevski
 
AWS for the Java Developer
AWS for the Java DeveloperAWS for the Java Developer
AWS for the Java DeveloperRory Preddy
 
Signal r azurepresentation
Signal r azurepresentationSignal r azurepresentation
Signal r azurepresentationJustin Wendlandt
 
R2DBC - Good Enough for Production?
R2DBC - Good Enough for Production?R2DBC - Good Enough for Production?
R2DBC - Good Enough for Production?Olexandra Dmytrenko
 
Patterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 appsPatterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 appsPhil Leggetter
 
React && React Native workshop
React && React Native workshopReact && React Native workshop
React && React Native workshopStacy Goh
 
EXPERTALKS: Jul 2012 - Build using Gradle
EXPERTALKS: Jul 2012 - Build using GradleEXPERTALKS: Jul 2012 - Build using Gradle
EXPERTALKS: Jul 2012 - Build using GradleEXPERTALKS
 
A year with event sourcing and CQRS
A year with event sourcing and CQRSA year with event sourcing and CQRS
A year with event sourcing and CQRSSteve Pember
 
Kotlin db migration tool
Kotlin db migration toolKotlin db migration tool
Kotlin db migration toolKenji Otsuka
 
How to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that ScaleHow to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that ScalePhil Leggetter
 
APIdays Paris 2018 - Secure & Manage APIs with GraphQL, Ozair Sheikh, Directo...
APIdays Paris 2018 - Secure & Manage APIs with GraphQL, Ozair Sheikh, Directo...APIdays Paris 2018 - Secure & Manage APIs with GraphQL, Ozair Sheikh, Directo...
APIdays Paris 2018 - Secure & Manage APIs with GraphQL, Ozair Sheikh, Directo...apidays
 
Sustainable software development / Jätkusuutlik tarkvaraarendus
Sustainable software development / Jätkusuutlik tarkvaraarendusSustainable software development / Jätkusuutlik tarkvaraarendus
Sustainable software development / Jätkusuutlik tarkvaraarendusGreteStrandberg
 
Forcelandia Salesforce CI
Forcelandia Salesforce CIForcelandia Salesforce CI
Forcelandia Salesforce CIDaniel Hoechst
 
A (XPages) developers guide to Cloudant - MeetIT
A (XPages) developers guide to Cloudant - MeetITA (XPages) developers guide to Cloudant - MeetIT
A (XPages) developers guide to Cloudant - MeetITFrank van der Linden
 
Keeping Rails on the Tracks
Keeping Rails on the TracksKeeping Rails on the Tracks
Keeping Rails on the TracksRubyX
 

What's hot (20)

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)
 
AWS for the Java Developer
AWS for the Java DeveloperAWS for the Java Developer
AWS for the Java Developer
 
Signal r azurepresentation
Signal r azurepresentationSignal r azurepresentation
Signal r azurepresentation
 
R2DBC - Good Enough for Production?
R2DBC - Good Enough for Production?R2DBC - Good Enough for Production?
R2DBC - Good Enough for Production?
 
Patterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 appsPatterns and practices for building enterprise-scale HTML5 apps
Patterns and practices for building enterprise-scale HTML5 apps
 
React + Redux for Web Developers
React + Redux for Web DevelopersReact + Redux for Web Developers
React + Redux for Web Developers
 
React && React Native workshop
React && React Native workshopReact && React Native workshop
React && React Native workshop
 
EXPERTALKS: Jul 2012 - Build using Gradle
EXPERTALKS: Jul 2012 - Build using GradleEXPERTALKS: Jul 2012 - Build using Gradle
EXPERTALKS: Jul 2012 - Build using Gradle
 
SGCE 2015 REST APIs
SGCE 2015 REST APIsSGCE 2015 REST APIs
SGCE 2015 REST APIs
 
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
 
A year with event sourcing and CQRS
A year with event sourcing and CQRSA year with event sourcing and CQRS
A year with event sourcing and CQRS
 
Kotlin db migration tool
Kotlin db migration toolKotlin db migration tool
Kotlin db migration tool
 
RavenDB 4.0
RavenDB 4.0RavenDB 4.0
RavenDB 4.0
 
How to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that ScaleHow to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that Scale
 
React introduction
React introductionReact introduction
React introduction
 
APIdays Paris 2018 - Secure & Manage APIs with GraphQL, Ozair Sheikh, Directo...
APIdays Paris 2018 - Secure & Manage APIs with GraphQL, Ozair Sheikh, Directo...APIdays Paris 2018 - Secure & Manage APIs with GraphQL, Ozair Sheikh, Directo...
APIdays Paris 2018 - Secure & Manage APIs with GraphQL, Ozair Sheikh, Directo...
 
Sustainable software development / Jätkusuutlik tarkvaraarendus
Sustainable software development / Jätkusuutlik tarkvaraarendusSustainable software development / Jätkusuutlik tarkvaraarendus
Sustainable software development / Jätkusuutlik tarkvaraarendus
 
Forcelandia Salesforce CI
Forcelandia Salesforce CIForcelandia Salesforce CI
Forcelandia Salesforce CI
 
A (XPages) developers guide to Cloudant - MeetIT
A (XPages) developers guide to Cloudant - MeetITA (XPages) developers guide to Cloudant - MeetIT
A (XPages) developers guide to Cloudant - MeetIT
 
Keeping Rails on the Tracks
Keeping Rails on the TracksKeeping Rails on the Tracks
Keeping Rails on the Tracks
 

Similar to Beyond The Rails Way

What serverless means for enterprise apps
What serverless means for enterprise appsWhat serverless means for enterprise apps
What serverless means for enterprise appsSumit Sarkar
 
Think Cloud, Develop Locally
Think Cloud, Develop LocallyThink Cloud, Develop Locally
Think Cloud, Develop LocallyAll Things Open
 
Cloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a CacheCloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a Cachecornelia davis
 
Web Automation Testing for developers?
Web Automation Testing for developers?Web Automation Testing for developers?
Web Automation Testing for developers?Victor Kushchenko
 
How to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJSHow to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJSPhil Leggetter
 
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 MondayBizTalk360
 
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...Thibaud Desodt
 
SOA with Zend Framework
SOA with Zend FrameworkSOA with Zend Framework
SOA with Zend FrameworkMike Willbanks
 
Service Architectures At Scale - QCon London 2015
Service Architectures At Scale - QCon London 2015Service Architectures At Scale - QCon London 2015
Service Architectures At Scale - QCon London 2015Randy Shoup
 
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdfWessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdfWessel Loth
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless ArchitectureDirk Weibel
 
Pros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitecturePros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitectureAshwini Kuntamukkala
 
From Zero to Serverless (CoderCruise 2018)
From Zero to Serverless (CoderCruise 2018)From Zero to Serverless (CoderCruise 2018)
From Zero to Serverless (CoderCruise 2018)Chad Green
 
Neotys PAC - Ian Molyneaux
Neotys PAC - Ian MolyneauxNeotys PAC - Ian Molyneaux
Neotys PAC - Ian MolyneauxNeotys_Partner
 
Tech Talk on Cloud Computing
Tech Talk on Cloud ComputingTech Talk on Cloud Computing
Tech Talk on Cloud ComputingITviec
 
Lessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxLessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxapidays
 
From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)Andrzej Krzywda
 
Scaling Your Applications with Engine Yard Cloud
Scaling Your Applications with Engine Yard CloudScaling Your Applications with Engine Yard Cloud
Scaling Your Applications with Engine Yard CloudEngine Yard
 
Angular Owin Katana TypeScript
Angular Owin Katana TypeScriptAngular Owin Katana TypeScript
Angular Owin Katana TypeScriptJustin Wendlandt
 

Similar to Beyond The Rails Way (20)

What serverless means for enterprise apps
What serverless means for enterprise appsWhat serverless means for enterprise apps
What serverless means for enterprise apps
 
Think Cloud, Develop Locally
Think Cloud, Develop LocallyThink Cloud, Develop Locally
Think Cloud, Develop Locally
 
Cloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a CacheCloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a Cache
 
Web Automation Testing for developers?
Web Automation Testing for developers?Web Automation Testing for developers?
Web Automation Testing for developers?
 
How to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJSHow to Build Front-End Web Apps that Scale - FutureJS
How to Build Front-End Web Apps that Scale - FutureJS
 
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
 
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...
 
SOA with Zend Framework
SOA with Zend FrameworkSOA with Zend Framework
SOA with Zend Framework
 
Service Architectures At Scale - QCon London 2015
Service Architectures At Scale - QCon London 2015Service Architectures At Scale - QCon London 2015
Service Architectures At Scale - QCon London 2015
 
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdfWessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
Wessel Loth - Fire your Frontend Framework with Lit - TEQnation 2022.pdf
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless Architecture
 
Pros & Cons of Microservices Architecture
Pros & Cons of Microservices ArchitecturePros & Cons of Microservices Architecture
Pros & Cons of Microservices Architecture
 
From Zero to Serverless (CoderCruise 2018)
From Zero to Serverless (CoderCruise 2018)From Zero to Serverless (CoderCruise 2018)
From Zero to Serverless (CoderCruise 2018)
 
Neotys PAC - Ian Molyneaux
Neotys PAC - Ian MolyneauxNeotys PAC - Ian Molyneaux
Neotys PAC - Ian Molyneaux
 
Einführung in RavenDB
Einführung in RavenDBEinführung in RavenDB
Einführung in RavenDB
 
Tech Talk on Cloud Computing
Tech Talk on Cloud ComputingTech Talk on Cloud Computing
Tech Talk on Cloud Computing
 
Lessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxLessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptx
 
From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)From legacy to DDD (slides for the screencast)
From legacy to DDD (slides for the screencast)
 
Scaling Your Applications with Engine Yard Cloud
Scaling Your Applications with Engine Yard CloudScaling Your Applications with Engine Yard Cloud
Scaling Your Applications with Engine Yard Cloud
 
Angular Owin Katana TypeScript
Angular Owin Katana TypeScriptAngular Owin Katana TypeScript
Angular Owin Katana TypeScript
 

More from Andrzej Krzywda

[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?Andrzej Krzywda
 
[PL] Service objecty to za mało - jak żyć z Railsami?
[PL] Service objecty to za mało - jak żyć z Railsami?[PL] Service objecty to za mało - jak żyć z Railsami?
[PL] Service objecty to za mało - jak żyć z Railsami?Andrzej Krzywda
 
Audit log with event sourcing
Audit log with event sourcingAudit log with event sourcing
Audit log with event sourcingAndrzej Krzywda
 
Event driven without microservices
Event driven without microservicesEvent driven without microservices
Event driven without microservicesAndrzej Krzywda
 
From legacy to DDD - 5 starting steps
From legacy to DDD - 5 starting stepsFrom legacy to DDD - 5 starting steps
From legacy to DDD - 5 starting stepsAndrzej Krzywda
 
Slack protips from Arkency
Slack protips from ArkencySlack protips from Arkency
Slack protips from ArkencyAndrzej Krzywda
 
DCI - the architecture from the future
DCI - the architecture from the futureDCI - the architecture from the future
DCI - the architecture from the futureAndrzej Krzywda
 
Service objects in Rails tests - factory_girl replacement
Service objects in Rails tests - factory_girl replacementService objects in Rails tests - factory_girl replacement
Service objects in Rails tests - factory_girl replacementAndrzej Krzywda
 
A programmer or a business consultant?
A programmer or a business consultant?A programmer or a business consultant?
A programmer or a business consultant?Andrzej Krzywda
 
Rails refactoring call for help
Rails refactoring call for helpRails refactoring call for help
Rails refactoring call for helpAndrzej Krzywda
 
[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchronicznaAndrzej Krzywda
 
Use cases in the code with AOP
Use cases in the code with AOPUse cases in the code with AOP
Use cases in the code with AOPAndrzej Krzywda
 
Single Page Applications with CoffeeScript [Polish]
Single Page Applications with CoffeeScript [Polish]Single Page Applications with CoffeeScript [Polish]
Single Page Applications with CoffeeScript [Polish]Andrzej Krzywda
 

More from Andrzej Krzywda (18)

[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
 
[PL] Service objecty to za mało - jak żyć z Railsami?
[PL] Service objecty to za mało - jak żyć z Railsami?[PL] Service objecty to za mało - jak żyć z Railsami?
[PL] Service objecty to za mało - jak żyć z Railsami?
 
Audit log with event sourcing
Audit log with event sourcingAudit log with event sourcing
Audit log with event sourcing
 
Event driven without microservices
Event driven without microservicesEvent driven without microservices
Event driven without microservices
 
From legacy to DDD - 5 starting steps
From legacy to DDD - 5 starting stepsFrom legacy to DDD - 5 starting steps
From legacy to DDD - 5 starting steps
 
Slack protips from Arkency
Slack protips from ArkencySlack protips from Arkency
Slack protips from Arkency
 
From legacy to DDD
From legacy to DDDFrom legacy to DDD
From legacy to DDD
 
DCI - the architecture from the future
DCI - the architecture from the futureDCI - the architecture from the future
DCI - the architecture from the future
 
Service objects in Rails tests - factory_girl replacement
Service objects in Rails tests - factory_girl replacementService objects in Rails tests - factory_girl replacement
Service objects in Rails tests - factory_girl replacement
 
Developer oriented
Developer orientedDeveloper oriented
Developer oriented
 
Can you TDD Rails?
Can you TDD Rails?Can you TDD Rails?
Can you TDD Rails?
 
A programmer or a business consultant?
A programmer or a business consultant?A programmer or a business consultant?
A programmer or a business consultant?
 
Rails refactoring call for help
Rails refactoring call for helpRails refactoring call for help
Rails refactoring call for help
 
[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna[Polish] Praca zdalna, praca asynchroniczna
[Polish] Praca zdalna, praca asynchroniczna
 
Use cases in the code with AOP
Use cases in the code with AOPUse cases in the code with AOP
Use cases in the code with AOP
 
Single Page Applications with CoffeeScript [Polish]
Single Page Applications with CoffeeScript [Polish]Single Page Applications with CoffeeScript [Polish]
Single Page Applications with CoffeeScript [Polish]
 
Madeleine on Rails
Madeleine on RailsMadeleine on Rails
Madeleine on Rails
 
TDD with Rails
TDD with RailsTDD with Rails
TDD with Rails
 

Recently uploaded

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Recently uploaded (20)

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

Beyond The Rails Way

  • 1. Beyond The Rails Way Andrzej Krzywda http://rails-refactoring.com
  • 2. Why is Rails business-friendly? • Quick to produce a prototype • Prototypes are production-ready enough • Easy to add new features • Possible to turn a prototype into proper production app
  • 3. Because of The Rails Way
  • 4. Why is Rails not business-friendly? • Because of The Rails Way • Business loves the speed of adding new features • … but loves predictability even more • There’s no predictability with The Rails Way
  • 5. The Rails Way • Scaffold-like code in controllers/views • ActiveRecord goes all the way up to the view • features implemented with external gems • external gems assume ActiveRecord in the views • all models connected to each other with associations • non-trivial things implemented with callbacks, filters, state-machine, STI, validations • some JS/Coffee on top of the server-rendered html • one monolith app • Convention over Configuration • Magic (relying on meta) • Don’t Repeat Yourself • “We’re 95% done with this app, can you help us finish it?”
  • 6. When is The Rails Way good? • for business/coding people to prototype • for less-experienced developers • to quickly get a result • for geniuses • they will handle any code • mostly-CRUD • logic-less apps
  • 7. When is The Rails Way bad? • advanced developers • complex business logic • long-living business processes (like order) • multiple teams • predictable speed of work
  • 8. If not The Rails Way then what?
  • 11. The Next Way • service objects • repositories • form objects • adapters • domain objects • events
  • 12. The Next Way is heavily influenced by DDD and classical OOP patterns
  • 13. It’s not all or nothing
  • 14. You can mix The Rails Way with The Next Way
  • 17. service objects are the gateway drug
  • 18. Gradually reduce the Rails magic
  • 20. We’re software developers, not software magicians
  • 21. Turn implicit into explicit.
  • 22. Turn conventions into explicit code
  • 23. Don’t Repeat Yourself We went too far with this rule.
  • 24. Coupling is worse than code duplication
  • 25. DRY examples • It’s OK to have different User classes for authentication, storage and for presentation • It’s OK to duplicate some code in controllers/services instead of relying on the controller filters
  • 26. The Next Way is just one possible set of techniques
  • 27. Other alternatives • DCI / Clean Ruby • CQRS • Event Sourcing • Ports & Adapters
  • 28. Choose what’s best for your project
  • 29. Experiments are OK (as long as you keep the app working)
  • 32. Your tests should be green all the time
  • 33. Learn how to refactor without any fear.
  • 34. Rails Refactoring recipes • Inline controller filters • Explicitly render views with locals • Extract render/redirect methods • Extract a SingleActionController class • Extract a routing constraint • Extract an adapter object • Extract a repository object • Extract a service object
  • 35. Thanks! “Fearless Refactoring: Rails Controllers” http://rails-refactoring.com still on a discounted price! (1.0 available from December 1st)