A reader asked me for quick recommendations on writing clean code. Here’s what I wrote back:

Clean code can be a number of things. For instance, a classmate of mine named Jim Gay likes a pattern called DCI for separation of concerns, and wrote a book about it (http://clean-ruby.com/).

But you may just mean “easy to maintain”. For that, there are a number of Rails best practices that can help in Rails, if that’s what you’re using at the time. You can even install a gem to check some of them automatically (https://github.com/railsbp/railsbestpractices).

Finding a style guide can help, though it will only get you so far. It’s easy to see how to improve a little, and the rules are well explained. Here’s the one GitHub uses internally: https://github.com/styleguide/ruby

To a large extent, just make sure you maintain your own code. Nothing else keeps you honest quite as well as using and maintaining your own stuff!