Towards Behaviour-Driven Programming

   Submit to Reddit      
  

Yes, I am a Behaviour Driven Development (BDD) man - and in this post I am limiting my discussion to Behaviour Driven Programming - the reframing of the very badly named Test Driven Development (TDD) practice. If in the future I find a better coding practice, I will switch to it, but at the moment this is the best I've found. I don't necessarily follow the practice to the letter, but I do exude the spirit of BDD.

In case you are unfamiliar with it, BDD (and its predecessor TDD) are all about developers designing their code - code that is simple to use, simple to maintain, squeaky clean, follows best practices (like SOLID development principles), and it just happens to result in the very welcome side-effect of an automated test asset suite. If you don't understand the benefit of automated tests already, then... I am sorry...

For almost two years now, I have been attempting to up-skill and convince various developers and teams and management at work about the benefits of BDD. The slow progress that has been made at work in no way correlates with my efforts - it is quite difficult to change the culture of teams. However, slowly and surely, I am happy to say that progress is being made.

Late last Friday night, I was showing a well-intentioned developer how he could perform behaviour tests on his code. We started by trying to retrofit the tests to his code, but it was quite smelly to say the least. In addition, because of the structure of the code, we were struggling to identify the valuable test cases we would create. In my disbelief, I quickly reached the point where I blurted out something along the lines of "if it were written using BDD/TDD practices in the first place, then we wouldn't be having this trouble" - and it was true.

FLASH! It was one of those defined moments in history. I almost didn't realise what I had said, but then it sank in... and the door reopened to showcase the power of BDD/TDD...

We then scrapped most of the pre-written code, and in a Pair-Programming style I walked the developer through the process of how to write clean code and perform unit testing with the practice of BDD/TDD. The resulting code was clean, intuitive, highly maintainable (as it read like a story), and was easily tested.

We compared the code that he had written with the new code, and there was no contest - the BDD/TDD code was significantly better, and the tests were easy and quick to create.

BDD/TDD is the unavoidable "pit of success" that enables the writing of clean, high quality code with automated test cases.

Intellisense for ASP.NET Markup Not Appearing In Visual Studio 2008

   Submit to Reddit      
  

I recently came across the problem where the intellisense for ASP.NET markup was not appearing in Visual Studio 2008.

After doing a Google search, I had gathered and tried the following suggestions:

  • In Visual Studio: Tools ➞ Options ➞ Text Editor ➞ All Languages ➞ Turn on "Auto list members"
  • Reinstalling Resharper
  • Deleting the HKEY\Local Machine\Software\Microsoft\VisualStudio\9.0 registry node (which then prevented Visual Studio from running!)
  • Repairing Visual Studio
  • Uninstalling and then reinstalling Visual Studio

And still it didn't solve my issue - there was still no ASP.NET intellisense for me!

The solution was to right click on a .aspx page in my solution, select "Open With" and change the default setting back to "Web Form Editor".

Somehow, someway, this had changed.

Hopefully this will save someone else a few days of hassle!

Code Reviews Are Important!

   Submit to Reddit      
  

A few months ago I was reviewing some Visual Basic .NET code from a production application and I came across the following little gem.

Dim variable As Integer = CInt("1000")

There are so many things one could say. It just boggles my mind...

I admit, this code will not cause any problems, but it is low quality and sadly humorous.

Unfortunately this one line of code indicates a general lack of professional coding, and thus immediately raises concern for other code that is actually critical.

How and why did this code get into production?

Perhaps a static code analysis tool wasn't even used. (Perhaps static code analysis tools do not highlight this as an issue - I haven't tried!)

However, static code analysis tools will never completely identify all types of low quality code or bugs, and this is why I maintain that all code, regardless of who it was written by, should be reviewed by a more experienced peer before it passes through to the next stage of testing or release.

Quite simply, it is a matter of professionalism. If a client saw this code and understood its low quality nature, I am sure they would not be happy.

Introduction

   Submit to Reddit      
  

Welcome to my software development blog!