Behavior-Driven Development with NBehave

What it Behavior-Driven Development (BDD)?

This new development technique is an evolution of the well-known Test-Driven Development. It encapsulates the idea of the Domain Driven Design to use a Ubiquitous language which should break the boundary between Business and Technology. That way, BDD makes  sure that the business, developers, testers, analysts and managers use the same words with equal meaning

The BDD process looks like this:

A business user works with a business analyst to identify a business requirement. This is expressed as a story using the following template:

  • As a Role
  • I request a Feature
  • To gain a Benefit

The speaker, who holds the Role, is the person who will gain the Benefit from the requested Feature. Dan North has written a great article about stories. I advice you to read it if you feel that it’s not clear enough. Continue Reading…

Arranging Numbers at Random

Let’s say we want to arrange the numbers from 1 to 100 at random. This is a little confusing problem but there is a solution (not only one) for it. The basic way is the following: you have an array where you put your numbers, you generate a random number while this number is not contained in your array, then you add it to the array. Well, this method is very sluggish! When you add numbers to the array you decrease the size of the multitude of possible numbers. And when this size is too little, the while cycle loops very long until you get a random number, which is not already added to the array. Here is this example. I have used a stopwatch to count the necessary time for this method to finish. Continue Reading…