Why it happens to your code again and again?

Ruby on Rails is considered a universal framework for web application creation. So, whenever you develop something for the web with Ruby, Rails is your choice by default.

At the beginning of development, everything is super quick and straightforward. Then you add some gems, and they seem to fit perfectly. They even speed things up.


After a while, when you add more functionality and gems, you start to notice that some of the stuff does not fit very well. So you start using duct tape and super glue to stick everything together.

Things don't seem intractable, but you keep adding stuff, and at some moment you find yourself in a situation when every step forward becomes too painful.

You fix it in one place and it breaks in two others. You introduce new functionality and it conflicts with existing architecture. Don't even mention Rails version upgrades.

This happens because of as applications grow, they increase in complexity

Mess ratio

The bigger your app gets, the more mess you make, unless you're able to manage complexity.

This ability can come from two sources:

  • Complexity can be managed by developers if they are familiar with best practices.
  • The framework itself offers solutions and tools the suit your purpose.

The Rails framework is optimized for developer convenience. As your application grows, things become hairy pretty quickly. For example, remember conditional validations?

Developers who tend to rely on the Rails way become trapped: "Rails is good by default", she thinks, "so there's no need to learn special complexity management techniques"

What can you do?

To break the vicious circle of mess, you must improve your ability to manage complexity.

You might need to learn about concepts and aspects of complexity management. Here are some categories:

  • SOLID principles
  • Design patterns
  • Refactoring techniques
  • Architecture types
  • Code smell identification
  • Testing best practices

Or you can rely on tools. You can start using tools with modularity ideas built in, like Lotus or ROM. Of course, there is a less radical way. You don't always have the luxury of starting from scratch, but you can tweak Rails to provide some complexity management. Some of of the tools that may help you:

Of course, it's best to learn principles and great tools. Because if you use tools without understanding the underlying principles, they might hurt you ;)