SlideShare a Scribd company logo
Refactoring Rails
apps with RubyMine
Andrzej Krzywda
Arkency
Andrzej Krzywda
• Arkency
• Rails since 2004
• hundreds of Rails projects reviewed
Agenda
• Typical Rails problems
• Beyond The Rails Way - new patterns
• Refactoring recipes with RubyMine
Rails is great
• In the first month of development
• Quick results in almost no code
• Quick feedback loop
• Predictable speed
• Your customer loves you
• You love Rails
2.months.later
Typical Rails problems
• MVC is not enough
• first regression bugs
• slow tests
• slower progress
6.months.later
Typical Rails problems
• hidden dependencies
• implicit assumptions (aka Convention over
Configuration)
• security bugs!
• Rails upgrades are now projects on their own
with (huge) budgets
2.years.later
Typical Rails problems
Any questions so far?
New guidelines
• explicit > implicit
• reducing meta
• more building blocks
New patterns
• Inspired by:
• DDD
• Hexagonal Architecture
• DCI
• CQRS/Event Sourcing
The building blocks
• Service objects
• Repositories
• Adapters
• Form objects
• Domain objects
• RubyMine
Refactoring Rails applications with RubyMine
Extract a service object
• the gateway drug
• a training in refactoring
• turn a controller action into a method object
Questions?
Typical controller coupling
• new-action uses the ‘new’ view
• create-action uses the ‘new’ view
• edit-action uses the ‘new’ view
• ‘new’ view uses _form partial
• ‘edit’ view uses _form partial
• ‘edit’ action uses ‘edit’ view
• ‘update’ action uses ‘edit’ view
new
create
edit
update
new.haml
edit.haml
_form.haml
show.rsb
common/error_messages.rsb
The filters algebra
• Filters depending on each other
• The order is important
• Hard to decouple
• communication via @ivars
At the controllers/views level
everything is communicating
with each other via @ivars
Everything is depending
on instance variables
Controller instance
variables are the global,
mutable state
the Redmine project
• a project management tool
• contains a time-tracking module
• http://www.redmine.org/projects/redmine/wiki/
RedmineTimeTracking
• since 2007
• https://github.com/redmine/redmine
Refactoring Rails applications with RubyMine
Refactoring Rails applications with RubyMine
Refactoring Rails applications with RubyMine
RubyMine coding
• look at the existing concerns
• run the subset of tests
• keep refactoring
Refactoring Rails applications with RubyMine
Summary
• Typical Rails problems
• Refactoring example
• RubyMine support
• http://rails-refactoring.com/recipes/
Fearless
Refactoring: Rails
Controllers
Today 20% off with the
JETBRAINS coupon code!
http://rails-refactoring.com
Thank you!
Questions?

More Related Content

PDF
From Rails legacy to DDD - Pivorak, Lviv
PDF
Beyond The Rails Way
PDF
RubyConf Taiwan 2016 - Large scale Rails applications
PDF
RubyConf China 2015 - Rails off assets pipeline
PDF
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
PDF
Sustainable software development / Jätkusuutlik tarkvaraarendus
PPTX
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...
PPTX
Signal r azurepresentation
From Rails legacy to DDD - Pivorak, Lviv
Beyond The Rails Way
RubyConf Taiwan 2016 - Large scale Rails applications
RubyConf China 2015 - Rails off assets pipeline
Javantura v4 - Java or Scala – Web development with Playframework 2.5.x - Kre...
Sustainable software development / Jätkusuutlik tarkvaraarendus
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...
Signal r azurepresentation

What's hot (20)

PDF
Javantura v4 - The power of cloud in professional services company - Ivan Krn...
PDF
Node.js server side render in the Age of APIs - Full Stack Toronto 2017
PPTX
Info Tech presentation
PPTX
Developing Cross-Platform Web Apps with ASP.NET Core1.0
PPTX
R2DBC - Good Enough for Production?
PPTX
Using Tomorrow's CSS Today
PDF
From Heroku to Amazon AWS
PPTX
TypeScript and Angular2 (Love at first sight)
PPTX
Cross-platform JavaScript
PPTX
A (XPages) developers guide to Cloudant - MeetIT
PPTX
Vincent biret azure functions and flow (toronto)
PPTX
Vincent biret azure functions and flow (ottawa)
PDF
C# 9 - What's the cool stuff? - BASTA! Spring 2021
PPTX
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
PDF
VTi Knowledge Database: a LinkedData project
PPTX
Ruby on Rails: Outreach for Women, SF
PDF
PDF
SGCE 2015 REST APIs
PDF
SOA Latam 2015
PDF
Being With Rails App For 3 Years
Javantura v4 - The power of cloud in professional services company - Ivan Krn...
Node.js server side render in the Age of APIs - Full Stack Toronto 2017
Info Tech presentation
Developing Cross-Platform Web Apps with ASP.NET Core1.0
R2DBC - Good Enough for Production?
Using Tomorrow's CSS Today
From Heroku to Amazon AWS
TypeScript and Angular2 (Love at first sight)
Cross-platform JavaScript
A (XPages) developers guide to Cloudant - MeetIT
Vincent biret azure functions and flow (toronto)
Vincent biret azure functions and flow (ottawa)
C# 9 - What's the cool stuff? - BASTA! Spring 2021
Documenting an API for the First Time? Quick-Start Tips for Your First API Do...
VTi Knowledge Database: a LinkedData project
Ruby on Rails: Outreach for Women, SF
SGCE 2015 REST APIs
SOA Latam 2015
Being With Rails App For 3 Years
Ad

Similar to Refactoring Rails applications with RubyMine (20)

PDF
EmberCLI Rails: An Integration Love Story.
PDF
Ruby on Rails Vs. ASP.NET MVC
PDF
Riding IronRuby on Rails
PDF
React on rails v6.1 at LA Ruby, November 2016
KEY
Introduction to Rails
PPTX
Rtc 2016 -_landair_surveys_-_laser scanning_-_from_field_to_revit
PDF
Ruby on Rails Crash course
PPTX
Apache maven 2. advanced topics
PPTX
O365: Attack of the Clones
KEY
UPenn on Rails intro
PPTX
New in Visual Studio and TFS 2013
PPTX
Einführung in RavenDB
PDF
Full Stack Developer Course | Infinite Graphix Technologies
PPTX
Introduction to ASP.NET 5
PDF
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
PPTX
Means stack course in pune(etlhive)
PDF
How IT at Getty Images Brokers Cloud Services
PDF
Cloud-native Data
PDF
Cloud-Native-Data with Cornelia Davis
PDF
Next Generation Web Development Techniques with Cloud Foundry
EmberCLI Rails: An Integration Love Story.
Ruby on Rails Vs. ASP.NET MVC
Riding IronRuby on Rails
React on rails v6.1 at LA Ruby, November 2016
Introduction to Rails
Rtc 2016 -_landair_surveys_-_laser scanning_-_from_field_to_revit
Ruby on Rails Crash course
Apache maven 2. advanced topics
O365: Attack of the Clones
UPenn on Rails intro
New in Visual Studio and TFS 2013
Einführung in RavenDB
Full Stack Developer Course | Infinite Graphix Technologies
Introduction to ASP.NET 5
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Means stack course in pune(etlhive)
How IT at Getty Images Brokers Cloud Services
Cloud-native Data
Cloud-Native-Data with Cornelia Davis
Next Generation Web Development Techniques with Cloud Foundry
Ad

More from Andrzej Krzywda (19)

PDF
[PL] PRUG Luty 2022 - Service objecty to za mało - jak żyć z Railsami?
PDF
[PL] Service objecty to za mało - jak żyć z Railsami?
PDF
Audit log with event sourcing
PDF
Event driven without microservices
PDF
From legacy to DDD - 5 starting steps
PDF
Slack protips from Arkency
PDF
From legacy to DDD (slides for the screencast)
PDF
From legacy to DDD
PDF
DCI - the architecture from the future
PDF
Service objects in Rails tests - factory_girl replacement
PDF
Developer oriented
PDF
Can you TDD Rails?
PDF
A programmer or a business consultant?
PDF
Rails refactoring call for help
PDF
[Polish] Praca zdalna, praca asynchroniczna
KEY
Use cases in the code with AOP
KEY
Single Page Applications with CoffeeScript [Polish]
PDF
Madeleine on Rails
PDF
TDD with Rails
[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?
Audit log with event sourcing
Event driven without microservices
From legacy to DDD - 5 starting steps
Slack protips from Arkency
From legacy to DDD (slides for the screencast)
From legacy to DDD
DCI - the architecture from the future
Service objects in Rails tests - factory_girl replacement
Developer oriented
Can you TDD Rails?
A programmer or a business consultant?
Rails refactoring call for help
[Polish] Praca zdalna, praca asynchroniczna
Use cases in the code with AOP
Single Page Applications with CoffeeScript [Polish]
Madeleine on Rails
TDD with Rails

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Big Data Technologies - Introduction.pptx
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Modernizing your data center with Dell and AMD
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
Empathic Computing: Creating Shared Understanding
The Rise and Fall of 3GPP – Time for a Sabbatical?
Big Data Technologies - Introduction.pptx
Transforming Manufacturing operations through Intelligent Integrations
Sensors and Actuators in IoT Systems using pdf
Review of recent advances in non-invasive hemoglobin estimation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
madgavkar20181017ppt McKinsey Presentation.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Modernizing your data center with Dell and AMD
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
NewMind AI Weekly Chronicles - August'25 Week I
20250228 LYD VKU AI Blended-Learning.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The AUB Centre for AI in Media Proposal.docx

Refactoring Rails applications with RubyMine