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.
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.
“I have not come across such a revelatory approach to things since first learning OOP.” — Mike Pence, Owner at Hayduke Labs, LLC
Finding yourself walking through code with a debugger means it's probably time to take a step back and rethink.
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!
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.
“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
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.
Grab a copy and get:
Get Clean Ruby for less than the cost of an hour’s worth of your time for only $49 in PDF, ePub, and mobi.
Jim is 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, ArrrrCamp and RubyNation, co-founder of Arlington Ruby and has been professionally building Ruby and Rails applications since 2006.
“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”
“Your approach to DCI is the most actionable, most practical explanation I’ve seen so far.” — Jeremy Weiland, Owner of 6th Density LLC
“Clean Ruby from Jim Gay will change the way you design your Rails apps.” — Hector Sansores
“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
“Just finished @saturnflyer book: Clean Ruby. So far, a good read. You need to buy this!” — Rob Evans
“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