In a legacy Rails app, drink every time…

When maintaining a legacy Rails apps, drink every time…

  • …the code gives up on basic indentation
  • …you find a database access more than four layers deep from the controller/job
  • …you find an untouched test, view, or migration file from ‘rails generate’
  • …there’s an explicit require to monkeypatch an autoloaded file of the same name
  • …you realize a fix is sabotaged by nil
  • …you find another model layer
  • …you find code that never worked
  • …a database schema is justified by legacy code that was decommissioned more than a year ago
  • …the only way to prevent a future bug is a sternly worded comment
  • …code only works because an invalid model was passed to it
  • …someone reverts part of your cleanups
  • …you find an implicit, ad-hoc state machine
  • …after the second time you find a totalizing js framework (ember, angular, backbone, etc.
  • …you find a directory under spec/test/feature the test runner skips
  • …a dev misapplied DRY so they could play with metaprogramming
  • …a random script is far better written than the app’s core feature (fortress of solitude)
  • …a dev justifies a bug in untested code by incorrectly claiming static typing wouldn’t catch it
  • …you find an abandoned selenium test suite for functionality with no other tests
  • …you hear “I know you’re cleaning things up, but ______ is not worth your time”
  • …code deliberately bypasses validations (“why do we even have that lever?”)
  • …you reify a core app concept for the first time
  • …you find another repo that still doesn’t bring the app over 50 KLOC
  • …you track a bug to a commit whose entire log message is “squashed”
  • …even Rails’s support for database constraints would’ve caught the bug
  • …a bug exists in local dev but not in prod
  • …a module mixed into only one model depends on another module only mixed into that model
  • …you find a new technique for passing data to javascript
  • …Rails core is invoked to win an argument (via 355E3B)
  • …the last test was added two pivots ago

…I could do this all day, except then I would have to dwell on the fact that I do this all day.

Have a Legacy Rails App?

If you’re laughing because you know this list isn’t satire, sign up below. I send newsletters once or twice a month on how to avoid and get out of these messes. I’m also trying to gauge interest in a screencast series about legacy Rails apps, so signing up is a vote for that.

Leave a Reply

Your email address will not be published. Required fields are marked *