Wednesday, November 18, 2009

Behavior Driven Development

After my last post on metrics, I came to the realization that what would be a much better approach to testing would be to focus on Behavior Driven Development. This methodology focuses on the use of scenarios to describe a small piece of functionality. Given its natural language approach to describing things, it provides an easily understood description of the requirements. For example:

Scenario 1: Refunded items should be returned to stock

  • Given a customer buys a black jumper
  • and I have three black jumpers left in stock
  • when he returns the jumper for a refund
  • then I should have four black jumpers in stock
From this, new advances in DSLs would provide a potential bridge to generate functional code to validate the requirements have been met. It seems to me this would provide a much higher value from a testing and code quality perspective as you are now writing tests that are 1) driven directly by the requirements; 2) oriented at a piece of functionality that directly affects the user.

Of course, some situations make this a difficult approach to use. For example, in my team's case, framework and API development would be somewhat more challenging to apply this approach. In order to overcome the lack of user-oriented scenarios, it may be necessary to approach it from an API-consumer perspective. A DSL here would perhaps help to bridge this gap, but still doesn't quite give the same clean application. Still, it seems like the benefits are there.

Something for us to consider as we move forward with our next release starting in January...

Tuesday, November 17, 2009

Metrics - Are they useless?

In the early stages of our project, we set a goal for ourselves of 70% code coverage. Besides not being reasonable or attainable given our deadlines, in the end, what did it really do for us?

Is pure code coverage effective at eliminating defects? In my opinion, the clear answer is 'No'. Though admittedly our code coverage in our last release was significantly higher than the release before, and our defect rate was significantly lower, I'd suggest that improved quality was due to other factors including a much cleaner and less-complex design.

In the end, I'd say that code coverage like other metrics are just a glance at the quality of your code. Use it for what it is - a tool and don't lean too heavily on it, otherwise you just might fall :)

Back to blogging - at long last

After a lengthy hiatus, I have regrouped and started a blog again. My old blog at http://1pcgeek.com fell to the wayside after a number of technical problems with the blog hosting app left me frustrated.

I've missed sharing some of the successes and failures of my day-to-day hobby, which also happens to be part of my job. I love software development. It's a great creative outlet.

Glad to be back...