Does My Rails App Need a Service Layer?

Sometimes during domain modeling you come across something that isn’t a thing. These operations that don’t quite belong to an object are called services. Services often live in a separate, service layer. The service layer lies between controllers and models, defining an application’s interface, its API.

Designing with services and a service layer is popular in the Java J2EE/Spring community. However, it’s not common in the Rails world. Is this because of the Ruby community’s general backlash against the complexity of Java? Or has the rise of HTTP-based JSON APIs made this architecture obsolete? To answer these questions, let’s take a deeper look at services and the benefits of a service layer.

Continue reading
Posted in Web | Tagged , , , | 18 Comments

Exploring Client-side MVC with Backbone.js

Backbone.js continues to gain popularity in the JavaScript MVC community. I decided to give it a try by creating a simple, single-page app to CRUD a single domain model.

While it wasn’t as trivial as a traditional server-side implementation in Rails, it did turn out relatively clean. This is a long post, and if you make it through it, let me know what you think.

Continue reading

Posted in Web | Tagged , , , | 7 Comments

Configuration for Rails, the Right Way

I still see people promoting various gems and plugins to handle miscellaneous configuration elements for your application. One little known secret is that Rails 3 allows you to define your own configuration elements trivially.

In this case, I wanted to use the nifty wkhtmltopdf utility to create a PDF. I was able to call the binary just fine with Homebrew on OSX but found that I had to use a custom binary checked into git for our production environment on Heroku. So I created a configuration variable to store where wkhtmltopdf could be found in the current environment.

First, we define a default value for all environments in config/application.rb:

module Configurator
  class Application < Rails::Application
    # By default, let OSX resolve the path to the binary
    config.wkhtmltopdf = "wkhtmltopdf"
  end
end

Then we override the default setting as necessary in config/environments/:

Configurator::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # Point Heroku explicitly to the binary we need to use
  config.wkhtmltopdf = "#{Rails.root}/bin/wkhtmltopdf"
end

Lastly, we access the configuration element in our code:

  cmd = [Configurator::Application.config.wkhtmltopdf, url, tmpfile.path]

Yes, that’s it. Just use Rails’s environment support and config to store your own configuration elements. They’re trivial to set, trivial to access and require no third-party gems or custom text files.

Posted in Everything Else | 27 Comments

Why We Are an Agile Shop

Last week we had a lively discussion about Agile development at Carbon Five. It was fun telling the story of how we got started with Agile nearly a decade ago. We discussed how it helps us deliver value and deal with the challenges we face as a services company. Here’s a summary of that conversation…

How does Agile help us to do better work for our clients?

To answer that question, I think it’s important to reflect on what makes building a product hard. Here’s a clue: Everything.

Continue reading

Posted in Process | Tagged , , , | 7 Comments

Event: Our Experience Building OVEE on 12/6

We just wrapped up the first phase of a project for ITVS, the Independent Television Service, and want to share the experience. We built OVEE, the online video engagement experience, on a short schedule with a small team. OVEE is a highly-interactive application built using node.js, mongodb, and a slew of other new tools/frameworks.

Our talk is going to cover product design, process and technology. We want to share the whole experience of building a product, not just the technical details.

Product Design Topics

  • Design and development process
  • Usability testing
  • Prioritizing features to match a budget

Technical Topics

  • Overview of the architecture and technical stack (node.js, express, jade, socket.io, flash, etc)
  • Using development spikes to reduce technical risk
  • Testing node.js
  • Lessons learned

After our talk we’ll turn it around and open the floor for those in attendance to share their relevant experience, in 5-10 minute mini-talks.

Additional details and RSVP: http://c5-the-ovee-story.eventbrite.com/

Posted in Process | Leave a comment

Explorations in Go: solving the Instagram engineering challenge

The good folks at Instagram posted a fun challenge on their engineering blog recently:

"Your challenge, if you choose to accept it, is to write a simple script that takes a shredded image in as input and outputs an unshredded and reconstituted image. That is, imagine if you took an image, divided it into an even number of columns and shuffled those columns randomly to produce a shredded image. Then, take that image into the script and output the original image."

(The original post is here: Instagram Engineering Challenge: The Unshredder).

This struck me as a great opportunity to hack out some code in Go (rev 60.1) as part of my continuing exploration of the language and its packages.

Continue reading

Posted in Everything Else | 2 Comments

Generating realistic-looking stories in Pivotal Tracker

We are heavy users of Pivotal Tracker here at Carbon Five, and each project evolves workflows around its use. I recently spent some time writing a Chrome extension to help support some of the common interaction patterns that come up in our workflows.

This blog post is not about that.

I started to write up a post about the Chrome extension and how I developed it (forthcoming), but realized that I needed to show screenshots. Unfortunately, I can’t use images of a client’s production tracker. Hmm.

I quickly whacked together a Ruby script to generate realistic-looking stories in a tracker project. Here it is!

Continue reading

Posted in Everything Else | 2 Comments

Modern Cucumber and Rails: No More Training Wheels

Last month, cucumber-rails 1.1 was released. This release removed web_steps.rb, a collection of step definitions for interacting with a web app.

For months, web_steps.rb contained a warning of its negative effects on feature maintenance. Like most developers, I ignored the warning. During a recent upgrade of an existing Rails app, I realized it was now gone. Instead of copying and pasting it from an older app or using the newly created cucumber-rails-training-wheels gem, I decided to accept the challenge and refactor its steps out of the app’s existing features.

After the refactor, the features read much better. They were simpler, less verbose, and felt more maintainable. I also cleaned up my factory_girl usage, which was causing issues similar to web_steps.rb. Here’s a short overview of the main refactorings.

Continue reading

Posted in Process, Web | Tagged , | 14 Comments

Why Your Daily Standup Sucks (and how to fix it)

The daily standup is the “Hello World” of agile development. It’s a daily, 15-minute meeting, about the current status of a project. Each participant answers three questions: what did I do yesterday, what am I doing today, what is in my way. Sounds simple, right? However, it’s surprisingly easy to turn a standup into another useless meeting.

Let’s look a few common standup “smells” and how to fix them.

Continue reading

Posted in Process | Tagged , | 37 Comments

Up and Running with Clojure

For the last three years or so, Clojure has been a language that I admired from afar: the design of the language is wonderful but I’ve never really used it to build anything and haven’t looked closely at the language in a while. Recently we had a Carbon Five tech showdown between Node.js and Ruby to see which system could pump out “Hello World” as fast and as consistently as possible. Since then we’ve added a Go version that impressed us a lot.

But we’re missing a JVM-based entry which gives me a great excuse to dive into the Clojure world and learn how things work.

Continue reading

Posted in Web | 16 Comments