You can't afford complicated code.

Writing small and easily testable methods can certainly clean things up, but as your application grows your classes start to know too much. Large classes means a large cognitive overhead for understanding how things work, or why they don’t.

It would be great to keep related things closer together. If this needs that to function, why aren't they right in front of your face? You might have broken things up well, but each time you search around for related code it begins to feel like a mess.

The more time you need to understand your code and keep it well organized, the more expensive your project becomes.

With organization like this, you have to keep more and more in your head as you dive deeper.

Reviewing and understanding code takes time and the more time you spend the more money you burn. Business owners turn to you to churn out features that are valuable to their businesses.

With every feature you add, your codebase is getting harder to manage.

Perhaps you even argue about the merits of documenting your code. Sure, you may strive to make your code more readable but actually reading it doesn’t reveal how your application works as obviously as it should, and falling back to documentation isn’t going to change your code. That’s bad news when you’re doing maintenance work and even worse for newly hired developers.

Finding yourself walking through code with a debugger means it's probably time to take a step back and rethink.

Even hiring a new developer means everyone needs to slow down to get him or her oriented with the code.

Object oriented programming is supposed to make this easier.

While following the Model View Controller approach has made your code cleaner, and following conventions have reduced the need for documentation, there’s still plenty of room for improvement and too much time needed to instruct new developers. MVC was meant for reflecting the end user’s mental model but it still makes it too easy to hide the intentions of your program in your code.

“Your ability to reason about your program is critical to debugging”
— Rich Hickey, Creator of the Clojure programming language.

Sending developers to read docs, wikis and tests just to understand your system is a time-consuming and oft-ignored task. Ruby code should be readable!

Wouldn’t it be so much better to open up a project and have it fit like a glove?

If there was a way to write code that un-complicated the logic and put it in plain view, that would make things so much clearer. If you could write the business use cases in easy to read Ruby code, you’d be programming with a smile every day knowing all your effort is right where it needs to be.

You can make this happen and Clean Ruby will teach you how.

“His book is one of the three or so most influential Ruby books I've yet read, and easily in the Top Ten for my career.” — Jeff Dickey

“I have not come across such a revelatory approach to things since first learning OOP.”
— Mike Pence, Owner at Hayduke Labs, LLC

Make your code more obvious and put the logic right where you expect it; read “Clean Ruby” and enhance your MVC design with DCI.

Data, Context, and Interaction (DCI), was created by Trygve Reenskaug (whom you may know as the creator of MVC) to make your code read the way it behaves. Pull everything out of its hiding place with “Clean Ruby” and learn how using the DCI paradigm means readable code and a super fast learning curve for your newest team members.

“The purpose of DCI is to produce code that a person can read and understand and so reason about its correctness”
— Trygve Reenskaug

With this and following East-oriented Code principles you'll push responsibility into the right objects. Use it to restrict the use of if statements which reproduce like cracks in a windshield.

And with that you’ll have a team that understands the business needs better than ever leading to better code, fewer bugs, lower costs, and happier customers.

“Your approach to DCI is the most actionable, most practical explanation I’ve seen so far.”
— Jeremy Weiland, Owner of 6th Density LLC

The Clean Ruby Plus package

Grab a copy and get:

Learn to think about thinking. At the basis of every program lies a human being's mental model. Creating a program which accurately reflects a shared mental model is crucial to building habitable and maintainable systems.

East-oriented code. Learn how to better understand encapsulation and create code which enforces that the right objects have the right responsibilities.

Forwarding, Inheritance, Delegation cheatsheet. Breeze through the quick refrence for forwarding with Inheritance, Consultation, and Delegation.

Visualization of message handling. Get this cheatsheet giving you a fast understanding with visualizations of how messages are handled by method_missing, SimpleDelegator, DelegateClass, and Forwardable helping you know how and when to use them.

Save hours of time avoiding reading through blog posts and documentation by getting the book and these additional PDF resources for only $99

“Clean Ruby by Jim Gay is the most engaging and fun tech book I've read all year.” — David Brady

Story from a reader:

“I always get so frustrated trying to dig through a project (new or old, right?), and trying to trace the flow of execution and how things fit together. This made me think of a project I worked on a few years back (which thankfully had a substantial logging capability) where I wrote a little perl script that would parse logs files and show how things were linked together. It was a very popular utility with the other devs and I was always curious, 1) why no one had written something like it before me; and 2) why the code wasn't just organized differently.” — Anthony Burton

Just the ebook

Or get just the ebook to:

Learn to think about thinking. At the basis of every program lies a human being's mental model. Creating a program which accurately reflects a shared mental model is crucial to building habitable and maintainable systems.

East-oriented code. Learn how to better understand encapsulation and create code which enforces that the right objects have the right responsibilities.

Get a sample chapter!

Send me your email and I'll send you a sample and you'll be on the list for more tips and articles about cleaning up your code.

Email: (required)

Name:

About Jim Gay

Jim is author of Ruby DSL Handbook, the Lead Developer for Radiant CMS and is a prolific contributor to it and many open-source projects. At Saturn Flyer LLC he’s built numerous Radiant sites, custom applications, and award winning graphic design and has had his designs published in HOW Magazine and The Best of LogoLounge. He’s been a co-host of the Ruby 5 podcast, speaker at RubyConf 2013, RubyConf 2014, Ruby Kaigi, Wroclove.rb, ArrrrCamp, and RubyNation, co-founder of Arlington Ruby and has been professionally building Ruby and Rails applications since 2006.

What people are saying:

“I wish I were living inside Jim Gay's codebase” —Pat Shaughnessy

“I’ve seen Jim present on this topic and he’s at the forefront of applying this approach to Rails projects. I’m eagerly looking forward to reading his book.”
— Avdi Grimm, Author of “Exceptional Ruby” and “Objects on Rails”

“Clean Ruby, by Jim Gay, is one of the few programming books that caught my attention like this. Very well written, a perfect flow.”
— Alexandre Oliveira

“Jim is one of those rare people who can crank out award winning site designs, go and implement the backend Rails functionality, and be lead engineer for his project team… all on one project. I’ve seen him do it.

Jim is someone to watch out for, and get on your project if you can. (Especially with his upcoming book, which I think will rock the Ruby on Rails world a little bit, changing how the community thinks about large/complex Rails codebases.).“
— Ryan Wilcox, Owner, Principal Engineer at Wilcox Development Solutions and former co-worker

“It’s awesome that Jim Gay wrote a book about Ruby and DCI. Finally a book about full OOP and Ruby.”
— Andrzej Krzywda, Founder gameboxed.com

“Your book helps me raise my game.”
— Jim Finucane

“The current version of Clean Ruby is a great start on a critical topic. Learning how to keep code clear and understandable is useful for any kind of project. I’ve already applied a couple of ideas from the book to keep a project from mumbling in the shadows. I’m excited to see the rest.”
— David Richards, Fleet Ventures

Clean Ruby by Jim Gay is a book about writing code that makes you and others happy. Copyright 2013-2015. All rights reserved. Send jokes about your dirty Ruby to jim@saturnflyer.com. Or send questions, I like them too.