Ylan Segal

The REPL: Issue 4 - November 2014

Lagom is not Just for Swedes

Great article on DHH’s RailsConf 2014 keynote. Even though you can have a badly designed system with tests, let’s not throw out the baby with the bath water.

Collaboration is Other People

Jon Yurek writes a thoughful opinion about the use of style-guides. It’s not about the pendantry of the use of curly braces or spaces, but about working as a team, better communications and focus on the important things in the code.

36% smaller Rails memory footprint through Benchmarking

Great tale about finding a great win by running benchmarks, the power of open-source collaboration. One small pull request will benefit thousands of rails apps in the future :)

In defense of fat tools

The Unix philosophy is to build small things and connect them together. How small? That is the crux of the matter. In this post, Avdi shows why sometimes using slightly larger tools, correctly abstracted away can yield better results than roll-your-own simpler alternatives.

The REPL: Issue 3 - October 2014

The definitive guide to Arel, the SQL manager for Ruby

Recently I found myself doing pretty interesting things with relational databases that are way, way above what ActiveRecord allows you to do (even if I where to condone the use of SQL fragments like Person.order('YOUR_FIELD DESC'), which I don’t). Arel, which powers ActiveRecord is very powerful for that sort of thing, if a little under-documented. The post by Jiří Pospíšil helped out a lot.

Move Fast, Break Nothing

In the post (also a talk), Zach Holman describes how Github continues to innovate and add features to their product, without breaking existing functionality. This post is interesting at the technical level, but also covers how the do team and company structure and communication in a way that doesn’t weight them down. Highly recommended.

Refactoring From Model to View Helper to Null Object

Short post on using the Null Object Pattern. Polymorphism for the win!

Book Review: Being Agile - Ekas & Will

Leslie Ekas and Scott Will present a practical approach to Agile that balances the philosophy of the Agile Manifesto with the tools and techniques needed to navigate the roadblocks that those wishing to implement Agile encounter on a daily basis.

The authors are not shy about sharing their extensive experience building enterprise software. I found myself nodding along on more to one occasion while reading the many anecdotes from the field sprinkled throughout.

The book is well-organized. Each chapter is devoted to one of eleven techniques, which in turn is divided into principles, practices metrics and breakthroughs expected. Of course the authors save the bet for last: Continuous Improvement, wich is rightly presented as the bedrock of the Agile methodology. The constant drive for individuals, teams and organizations to constantly improve on their past performance is the essence of successful software development (and more broadly, I would argue, of any human endevour).

This work is a great addition to the bookshelf of team members or leaders just starting out or well on their way in their Agile adventure.


StringInquirer: Nicer Syntax for Testing Equality

There is a well-known idiom in Rails, to tell wheather one is runnign in a specifc environment or not:

Rails.env.production? # => false
Rails.env.development? # => true

At first, it looks like Rails.env is a special kind of object that has methods defined on it to check for the environment properties. However, upon closer inspection, it looks like it is really just a String, but not quite:

>> Rails.env
=> "development"
>> Rails.env.class
=> ActiveSupport::StringInquirer

As the documentation says, StringInquirer is just a pretty way to test for equality. It can be used outside of Rails, say for example to be a bit lenient when reading environment variables:

require 'active_support/core_ext/string'

class Logger
  def log(message)
    message if verbose?


  def verbose?
    env_verbose.true? || env_verbose.yes?

  def env_verbose
    @env_verbose ||= (ENV['VERBOSE'] ||= '').downcase.inquiry

Logger.new.log("Hello, World") # => nil

ENV['VERBOSE'] = 'yes'
Logger.new.log("Hello, World") # => "Hello, World"

Logger.new.log("Hello, World") # => "Hello, World"

ENV['VERBOSE'] = 'True'
Logger.new.log("Hello, World") # => "Hello, World"

Book Review: The Rails 4 Way - Fernandez & Faustino

“The Rails 4 Way”, by Obie Fernandez and Kevin Faustino is a great reference book that covers most of what a Rails developer is likely to need on a daily basis. It covers the various DSLs and idioms (i.e. route definition, controller filter declaration, ActiveModel association and validations, etc) without getting into the details of Rails internals and how those features are implemented. The explanations are clear and the code examples relevant.

Just like Rails itself, “The Rails 4 Way” is opinionated and occasionally differs from the omakase 1 way; Most notoriously, but hardly controversial, using Haml as a template engine and Rspec for testing.

Most of the book can be read cover-to-cover or used as a reference on particular topics. The exception is section about rails helpers (Chapter 11) which, as the author themselves point out, is really just an alphabetical listing of the methods available, like the one usually found on appendices or online documentation.

I recommend this book to new Rails developers (maybe after trying out an online tutorial) and for experienced Rails developers who are still working on Rails 3 (or 2!) and are expecting to make the jump to Rails 4 in the near future.

  1. Want a laugh? See the dramatic reading of DHH’s post