One of the difficulties of learning a new programming language, framework or technology is that of knowing whether you’re doing things in the best way. Tutorials and books can only take you so far, then after that you’re flying solo staring at a terrifying blank screen in your editor or IDE. Of course practice makes perfect and hopefully if you care about your craft then you will acquire knowledge of best practice with experience. But what to do in the meantime; how do you ensure that you’re not setting off on completely the wrong footing?
Ruby on Rails is one of the kinder frameworks that I’ve come across in this regard, in the sense that it puts a lot of infrastructure in place to guide you on your way. For example, the project directory structure is pre-canned and there’s a nice testing framework in place, which leaves you free to just write the actual tests. There are also lots of smart people writing blog posts stuffed full of really useful information. You’ll find links for a lot of the best ones over there on the right. Also highly recommended is PeepCode, where in return for a small amount of money you get about an hour of video with the amazingly productive Geoffrey Grosenbach teaching you one-on-one about various aspects of Rails.
It’s not all perfect though. Like many people, the first Rails book I bought was the first one that came out: Agile Web Development with Rails. Unfortunately Rails is such a fast-moving target at the moment that much has changed since the book was published. Which means that the copy of the book sat on my bookshelf is full of code examples illustrating approaches that are out of date, or in the worse case, deprecated or just plain dangerous! That’s hardly the authors’ fault, it’s just a natural corollary of the growing pains that Rails is experiencing as it matures. And a completely revised second edition is on the way.
Recently I’ve been thinking that it would be great if I could somehow get a Rails expert to perform a code review of my Rails code because I know there are areas where I could do things in a smarter way, or where I have a gut feeling that I’m using an old technique. By amazing coincidence two members of the Rails core team have just announced a site that will do exactly that. The Rails Way is a new creation from Jamis Buck and Michael Koziarski where they’ll review code submissions and publish how and why they’d have done it. I’m really looking forward to seeing how this one goes—I think it’s going to be a big hit. Thanks guys!
Talking of Rails, I’ve recently been writing lots of tests and learning how to do that properly. The first thing I did was to download and install autotest, which automatically runs the appropriate tests every time you save a changed file. That way you get instant feedback on whether your change was successful or not. I also installed a Ruby code coverage tool named rcov by following these instructions. That gives me a nice HTML report which shows how much of my application code is being exercised by my test code. This is the first time I’ve really followed TDD techniques so vigourously and it’s paying off handsomely by giving me a much greater confidence in the correctness of my code.
Comments
There aren’t any comments on this post. Comments are closed.