this is a blog by Jeff Perrin, a software developer based in calgary alberta

Here Be Dragons. Slay Them.

I've been somewhat facinated by Ruby on Rails for a while now. Initially, I'd watched the demo videos about the basics of the framework and was impressed by how nicely everything fit together (like most people, I'd imagine). The elegance of simplicity can sometimes be mind-bending, in a why didn't I think of that sort of way. There's nothing new there, it's just that the way in which it's been implemented is so damn... well... fan-fucking-tastic.

Perhaps the thing that I respect the most about Rails and it's developers, however, is the extent to which simple common sense was applied in it's creation. Over the many years of "enterprise" software development, certain things have become so entrenched within the mindset of developers that we've missed the original point of it all. For example, how many of us cringe when we see something like this?

<% foreach( Item item in LineItems ){ %>
    <p> <%= item.Name %> </p>
<% } %>

Most of us do, I'd bet. Sometime in the not-to-distant past, somebody realized that embedding a whole bunch of busness logic in with your views made things hard to manage. So they decreed "Thou shall not mix business logic with view logic" and the world was good again.

But look again at the code I've written above. Is there any business logic in there? No, there isn't any at all, actually. Yet we all still experience an allergic reaction at the sight of it. Why? Instead, we write things like in another language entirely, a templating language to be exact. So now, instead of the above code, we have a layer of indirection like so:

<asp:Repeater id="repeater" runat="server">
        <p><%# DataBinder.Eval(Container.DataItem, "Name") %>

Perhaps this is easier to read, perhaps not. There's certainly more to write. The fact remains that we haven't really changed anything. We still have two examples of view code that don't implement any business logic. Big deal, I guess.

My point, and I do have one, is that the most refreshing thing I see when I read my new book on Rails is the complete disregard the framework authors had for certain established norms. Rather that going ahead and implementing their own templating engine for views, they simply use Ruby. Pure craziness, I know. But it works, as long as you remember not to mix your view logic with your business logic. You don't need an entire new language to accomplish this. The dude who handles the GUI where I work (which is Struts based) will attest to the fact that a templating language does not necessarily prevent business logic from bubbling upwards through the layers anyways.

The Rails book I linked to above is chock-full of stuff like this. I highly recommend it, even if you don't ever write a line of Ruby in your life. Basic common sense is refreshing every now and then.

I Have the Power(book)

NewsGator Online is a Sexier Bloglines