Archive for the ‘Writing Reliable, Bug-Free Code’ Category

Showing the Git branch in your bash prompt

Posted by Rahoul Baruah on October 29th, 2008 under Beautiful Code, Writing Reliable, Bug-Free Code  •  2 Comments

y first adventure in source control was many years ago. It was my first proper job and I was the sole developer in a tiny company. To keep the source code safe, it was all stored on a network share, and the file server was backed up at least once a day. [...]

Telling Stories with RSpec

Posted by Rahoul Baruah on October 16th, 2008 under Designing Great Software, Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code  •  Comments Off

Last night I gave a talk at Geekup about RSpec and RSpec User Stories.  
 
Telling Stories With RSpec
View SlideShare presentation or Upload your own. (tags: ruby rails)

 
Thanks to Ashley Moran for talking it through with me.
UPDATED to use Slideshare to display the slides.

The Specification is the Documentation Part Two

Posted by Rahoul Baruah on August 5th, 2008 under Beautiful Code, Designing Great Software, Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code  •  Comments Off

Two (related) thoughts on “The Specification is the Documentation“.
One of the things that I like to do, when developing, is to start with a sketch (you know, with 95g/m2 paper and a 6B pencil) of how the UI will look. There are two reasons for this. Firstly, it helps communications with the client [...]

The Specification is the Documentation

Posted by Rahoul Baruah on August 1st, 2008 under Beautiful Code, Designing Great Software, Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code  •  1 Comment

In a former life I used to write “functional specifications”. These were long, dense, hard-to-read documents that detailed what an application (not yet written) was supposed to do. I would spend (literally) weeks typing these things up, the customer would read it, think they understand and I would quote them based upon the document. [...]

Setting up a mock object to test a :dependent => :destroy association in RSpec and Rails

Posted by Rahoul Baruah on July 10th, 2008 under Beautiful Code, Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code  •  Comments Off

One of the great advantages of using mock objects to test and specify your objects is that you concentrate solely on the thing you are testing.  
If you weren’t using mocks to tests that a controller re-shows the “new” form if given an invalid object, you would do post :create, :model => { … } where [...]

To DRY or not DRY?

Posted by Rahoul Baruah on July 9th, 2008 under Beautiful Code, Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code  •  1 Comment

A very interesting article about how DRY you should be in your specs.  
http://lindsaar.net/2008/6/24/tip-24-being-clever-in-specs-is-for-dummies
Personally I agree with everything said.  Readability comes first, even at the expense of efficiency and DRY; “be nice to those who have to maintain the code”.  The really interesting thing though is the example is actually quite DRY – it’s more [...]

Ruby on Rails Basics

Posted by Rahoul Baruah on May 21st, 2008 under Beautiful Code, Designing Great Software, Managing Successful Projects, Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code  •  Comments Off

Sometimes, it’s worth stating the basics for all to see:

Follow the Model-View-Controller paradigm.  In particular, your views house your user-interface, your models handle the application and your controllers mediate between the two.  Controllers do not contain rules, conditionals dealing with business conditions, queries looking for objects related to the one in question.  All those things [...]

Cross Platform Development – testing on both platforms

Posted by Rahoul Baruah on January 25th, 2008 under Managing Successful Projects, Writing Reliable, Bug-Free Code  •  Comments Off

Like a growing number of computer users, 3hv is an Apple Mac based company. Sometimes, this can lead to problems … most people use Microsoft Windows, which looks and works differently.
Never fear – since Apple switched to using Intel processors, companies such as VMWare and Parallels make it possible to run Mac software alongside [...]

Weird behaviour involving controllers, modules, namespaces and functional tests

Posted by Rahoul Baruah on December 10th, 2007 under Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code  •  Comments Off

Weird one here.
I was working on some code that had controllers within a namespace (Admin::ThingyController). The controller descended from an Admin::BaseController. And Admin::BaseController included a module (include GenericStuff), which in turn was defined within the Admin namespace.
So far, so good.
The code-base was actually somebody elses and the time came for me to add [...]

Incorrect Test Fixtures lead to Weird Testing Results

Posted by Rahoul Baruah on November 16th, 2007 under Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code  •  Comments Off

After recently praising test fixtures as an important (but time-consuming) part of building your tests, there is something to watch out for.
If you get one of your foreign key references wrong in your fixture data you can get odd results. In particular I had a test that passsed when run using ruby test/unit/my_test.rb but [...]