Lessons In Windows PowerShell - Introduction

   Submit to Reddit      

One of our Team Foundation Server build servers recently ran out of disk space. Upon closer investigation, we had 6 team projects building on that server, each with at least 3 different code branches, totalling more than 18 build folders - with each build folder larger than 2Gb. Do the maths, and that is essentially more than 40Gb being used.

Those folders however are not needed after a build has completed, and they can be safely deleted - so I decided that I would write a Windows PowerShell script to delete folders that haven't been written to for more than a day, and schedule the script to run through the Windows Task Scheduler.

Well, there was only one problem... I haven't really used PowerShell before. But, a couple of hours later, and I had the solution.

The start of this series of lessons reflects some of the lessons I quickly learned.

You can find more information on Windows PowerShell at the following links.

Towards Behaviour-Driven Programming - Part 2

   Submit to Reddit      

Today a small team of three had a post-iteration meeting, and for the first time within the company (I dare say), there was agreement about the benefits of BDD/TDD when automated tests are required. The team agreed that it takes significantly longer to retrofit automated tests than it does to do the coding and testing in a BDD/TDD fashion.

The main reason is because when BDD/TDD practices are followed, the code is designed cleanly from the start and it tends to naturally follow best practices. When tests were retrofitted, the code typically has to be refactored/restructured and sometimes even completely rewritten so that the test cases can be properly identified and then written.

This is a hard-earned and yet relatively small victory, and after a long amount of time, suffering and battling, I'm telling everyone who'll listen!

One step closer... critical mass... you are now in my sights!

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!