With over two years worth of rails development under my belt something happened to me the other day. Something clicked, and not only was I a professional Ruby on Rails developer by way of my job, but I also became a professional Ruby on Rails developer by way of my state of mind.

Let me explain myself in more depth.

I am sure when all developers start out in a new language and frame work, everything is shinny and new, and you jump on every cool new thing that comes out regarding your new toy and you just want to use it. I was like this when I first started using rails. I think back to when I first found out about haml (http://haml-lang.com/) and decided that it was so cool I wanted to totally abandon erb and use haml exclusively, I was also of the mind that those that did not use haml were a bit wrong in the head. Now I am not so sure about this, now I think that views should be kept as close to pure html as possible. I am a purist and an idealist. I do not like muddying the waters. Moving on in my rails life I was always searching for a book, blog post, screen-cast, something definitive that I could use to learn what I thought needed to be known to make me a professional rails developer not only by job title, but to also actually feel like one too. In my search I have read many posts, subscribed to (and removed) many rss feeds. Watched many screen-casts, been to a few conferences, and read the odd book here and there. All of these things have contributed to putting me in the frame of mind I have now. Which is not only am I a rails developer by trade, and I am also a rails developer by mentality. And I am sure that many developers have this feeling (or maybe it is just me), of wanting to do things the best and most professional way possible. To say that their code is the cleanest it can be. To say that the tests are as well written as they could be, to say the views are well written with close to zero percent logic in them. To say that the controllers are skinny, the models are fat, and nothing that belongs in one is in the other and vice versa. This is sort of the ideal. The place that you want to get to mentally where you are not just telling people you are a rails developer but you actually feel like it too. Well people I have obtained that feeling. I have reached my mecca.

I am a ruby, and ruby on rails developer. I am very content being so. I have no desire to work with technologies that are not related closely to this. So all you PHP disciples, Java-ites, Python preaches and others, it is great that you have a technology that works for you. I however, have less than no interest in the technologies that you use. Each to their own, and do whatever works for you. I just want to concentrate 100% on what I like to do and makes me happy doing and explore the new found world of mental professionalism that I have newly acquired.

If you read the byline of my blog it says something like “I am a user that just knows how to develop”, and while this is still true, I now also feel I have moved into the realm of professionalism. This is thanks to all my experience that I have had in everything I have done in the past 2.5 years using rails, and all other technologies that highlighted how great ruby and rails is compared to them. But these past 2 weeks 2 things tipped me over the professionalism line.

1. I watched a screen cast entitled What Killed Smalltalk Could Kill Ruby, Too“. This was tweeted by my friend and current colleague Leonardo Borges. I say current because Leo will be leaving us soon to join thoughtworks in a few months down in Australia. Good luck with that. Tell the locals G’day and give them hell down under. But I digress. This screen cast served to iron out the remaining bad habbits that I have in my mind, and sometimes currently put into practice. It also re-reminded me of how I should be developing. In short and to paraphrase from the film As Good As It Gets with Jack Nicleson, “It made me want to be a better man”. Sometimes if you have worked for sometime in a place of work like I have and you have tried to implement change for the better, you also get sucked into the bad habbits that were in place without even knowing, and lose sight of what you were trying to change in the first place. And this screen-cast was a great wake up call. If you have not seen this screen-cast it is well worth watching.

2. The second thing that tipped the scales of professionalism for me was looking at code for the past couple of weeks at my current place of work. What can I say? Looking at code like that makes me what to cry/tear my eyes out/get up and just leave the code alone/good to sleep and hope it is just one bad dream. Any and all of these things. We have been doing a transition from Prototype to jQuery (thank God), and looking through the code and the tests that go with the code makes me realise how far I have come and why code like this just not acceptable to me anymore.

These two things along with all the things I have gone through and have learnt over my time working with ruby and rails have made the developer I am today.

I can no longer stand to see javascript in the html, I cannot abide having css in the html either. I abhor rjs. Code with no tests make me feel very uneasy. Test written after the code has just seems useless to me. The use of a non distributed Source Control Manager is just crazy to me. And last but by no means least, the “get this done as quick as possible” mentality is one that despise, and which unfortunately is currently a part of my current job. When will people learn that short term gain does not outweigh the long term goal.

In the past I was reluctant to take on a lot of freelace work in rails because I still felt I was honing my skills. Now, I feel I could (and probably should, if for nothing but my own sanity and peace of mind) start up my own company where all these rules of coding are enforced. And good… no, great code is produced on a daily basis.

All of this brings me to the main point of this post. My Rails Lasagna. I will undertake to write a series of posts pointing out what I think makes a good Rails Lasagna. Let me first explain what I mean by a Rails Lasagna.

As we all (should) know, Lasagna is a layered dish. If made properly all layers are nicely separated from the others and you have something that not only looks good, but tastes good as well. And so in my analogy this is how my Rails Lasagna would be made up.

  • The cooking dish – This would of course be rails. This is the framework that holds everything together. This is where all the ingredients go. This is where everything gets cooked. This is Rails.
  • The base layer – The foundation all all good Rails Lasagnas should be testing. And not just testing, but test driven development, behaviour driven development, whatever you what to use. But tests must be first whether you use testunit, rspec or something else.
  • The meaty model layer – This should be a big fat juicy model layer. All of your juicy logic should be here.
  • The thin controller layer – Your controllers should be light and thin. Something beautiful to break up the taste of the meaty model layer below and the view layer above.
  • The view layer – This layer should be packed with all types of html goodness, and very low in logic cholesterol.
  • The css Layer  – This is the first layer people are going to see when they look at your Rails Lasagna, so this is your chance to make your Lasagna look as great as your want it to look.
  • The javascript layer – For those of you who like to dabble in the more advances techniques in cooking, this is where you get the chance to shine. Remember that in this layer, a lot of the time less is more. Use this to enhance your Lasagna, do not let this drive your recipe. And even when you do feel like you want to use this in your recipe, I would suggest you go for a ready mix solution. A nice jQuery, Prototype or mootools would do just fine here. Because unless you are a Michelin star javascript chef, why kill yourself doing what others who are, have taken the time to make as easy for you as possible.
  • The oven and the fridge – These are is your SCM, this is where you put your lasagna when it is cooking and when it is done. I would suggest that you get yourself one of the more modern distributed models of oven or fridges. Git, Mercurial and Bazaar are fine brands. They will serve you well. Try and stay away from older brands like SVN or CVS. While these markers were good in their day, they have not kept up with the times and make the whole cooking experience more painful and a whole lot less enjoyable.

So there you have it, a start for your Rails Lasagna. In the following posts that I write I will detail my thoughts on each of these parts for a great Rails Lasagna. Now sit back and enjoy that great Rails Lasagna aroma and taste.