Category Archives: Ruby

Why I like NetBeans 6.0

Roughly a week ago, the NetBeans 6.0 IDE (originally created by Sun) was released. And boy is it amazing; it even downloaded and installed the new Ruby on Rails 2.0.1 for me when I opened it for the first time.

I’ve always felt that Visual Studio is superior to any other IDE, with Eclipse being a close runner-up. That has changed now, and the new NetBeans is my new favorite for coding in anything but .NET. Just look at the code completion for Ruby, which includes a documentation window that pops up when you highlight a class in the list.

Also the way you can start your Rails site and surf around is great, it’s just like how you do it in Visual Studio. Just press F6 and a WEBrick server fires up and a browser window opens with your site in it. So smooth it makes your favorite milkshake blush.

It is open source, free, cross-platform, provides awesome tutorials (which Eclipse does too by the way) and the installer for the Ruby version is only 19 megabytes. 19 megabytes of love. It’s so good it almost makes me want to choose Java over C#. Almost.

It’s not very fast though… but then again, neither is Ruby. And no, I’ve never understood the Ruby community hype around TextMate, or vi and Emacs for that matter. To steep a learning curve for me…

Behavior-Driven Development

I’ve started looking at Behavior-Driven Development (BDD) and more specifically RSpec for Ruby. BDD is an evolution of Test-Driven Development (TDD) which aims to make developers look at it from another perspective and not regard it as testing in a sense. So it’s more of a new way of expressing your intent rather than an entirely new approach to tests (or specs as the BDD community calls it).

You divide your code into small pieces of behavior, rather than the more abstract term units and write what it should do.

Here are two examples of the difference:

NUnit (C#) RSpec
Assert.AreEqual(expected, actual) actual.should equal expected
Assert.IsTrue(bool) Bool.should be_true

Edit: I tried pasting some code I’d written here, but the wordpress editor sucks when it comes to formatting code. But you can find great examples here and here.

I just watched a video where Dave Astels (one of the guys behind RSpec) explains why you should take a look at BDD if you’re into TDD. To quote him: “Behaviour Driven Development is what you were doing already if you were doing Test Driven Development very well”. You can also read his PDF A new look at test-driven development (8 pages) where he explains his views and why too few people “really understand what it’s really about. That means that many people who practice TDD are not getting the full benefit from it”.