Re.Mark

My Life As A Blog

Archive for April 2006

Limits to Independence

leave a comment »

The solution I described yesterday has a drawback – it increases the scope of the created class. This may be acceptable – it may even be desirable – in some instances, but there are situations where you have to think of something else. In the case of nspectre, a reference ValidatorFactory needs to held for the lifetime of an application because it compiles the specifications once when they are first required. So, if we were to hold references at class level in ValidatorFactory, they would never be eligible for garbage collection.
Let's say we have a class called, uninspiringly, Foo that creates an instance of class called – you guessed correctly – Bar. One solution is to create a protected method in Foo that returns a new instance of Bar. In our unit tests we subclass Foo and override the newly created protected method. Then we can either extract the interface from Bar and make Bar implement this interface (IBar) and mock Bar in the unit tests. It would also be possible to return a fake Bar – maybe by subclassing Bar.

Written by remark

April 26, 2006 at 8:05 pm

More Independence

leave a comment »

Having put in a few logging messages into nspectre to prove the principle, it's time to test the logging messages. Given that the design relies on an ILogger interface, this is fairly easy with mocks. What I noticed fairly quickly was a class that created another class – which meant that testing logging would mean testing it in more than the target class.
The solution is to extract an interface from the class being created by the target class and pass it to the target class in the constructor. Now I can also mock the class that was being created. In this instance, the code that results is more elegant. All tests have been updated and they all pass. Once more the tests have proven their worth – this kind of refactoring would have been scary without them.

Written by remark

April 25, 2006 at 10:57 pm

Look Sharp

leave a comment »

The beta version 2.0 of Resharper is available. I've used and been impressed by Resharper. Just over a year ago, I was coming back to VS.NET, having been using Eclipse for a while. I was amazed how far behind the game Visual Studio was in support for refactoring. Version 2.0 of Resharper includes a built-in tool for running unit tests à la Test Driven .NET. Intriguing.

Written by remark

April 23, 2006 at 10:16 pm

Posted in Tools

Who owns the code?

leave a comment »

I found this an interesting read. The article suggests the role of a Code Steward whose job:

is not to safeguard against concurrent-access, but to instead safeguard the integrity+consistency of that code (both conceptually and structurally) and to widely disseminate knowledge and expertise about it to others.

The measure of success, of course, is that the Code Steward's role becomes unnecessary – enabling them to reprise the role on other projects.

Written by remark

April 20, 2006 at 8:05 pm

Posted in General

Performancing

leave a comment »

The new version of Performancing for Firefox is out (version 1.2) – this version includes access to your Performancing metrics.

Written by remark

April 19, 2006 at 10:13 pm

Posted in Tools

Sunday Post

leave a comment »

Most of the logging support for nspectre is done (in CVS but not released.)  I need to extend the support to the ConfigurationReaders to complete the job.  Of course logging support does not equal logging.  I’ve put some logging in to a couple of classes and a couple of templates to prove the principle, now I need to expand that across the codebase (including testing the logging.)

Written by remark

April 16, 2006 at 2:06 pm

Posted in nspectre

Feed me

leave a comment »

I’d just got around to looking at Feedburner, when WordPress posted this.  Excellent.

Written by remark

April 16, 2006 at 1:56 pm

Posted in General

Bring Your Own

leave a comment »

I have started to implement logging support for nspectre.  It will use a “Bring Your Own Logger” design.  What that means is that nspectre will define an ILogger interface and you’ll be able to write your own implementation of ILogger to use your preferred logging tool.  The first advantage of this approach is no hard dependency, which makes deploying nspectre much easier.  The second advantage is that it makes testing the logging easy – the interface means that NUnit mocks will do the trick.

Written by remark

April 13, 2006 at 7:08 pm

Posted in nspectre

The Ubuntu X Factor

leave a comment »

Having upgraded from Breezy Badger to Dapper Drake, I had an old Breezy Badger image laying around that I wasn’t going to use. Having used xfce in the past and coming across Xubuntu, I decided to migrate my Breezy Badger image to Xubuntu.  The instructions here don’t mention that you need to comment your CD-ROM drive out of the sources.list file if, like me, you have a pre-built VM image (and, therefore, don’t have the CD.)
Unsurprisingly, it works.  The xfce desktop is really responsive.   There’s something about being able to swap the entire desktop experience that appeals to me.  I got an image of Ubuntu in order to have a working Mono environment.  I’m starting to think about using it as the primary OS (on an old machine.)

Written by remark

April 11, 2006 at 6:48 pm

Posted in General, Open Source, Ubuntu

Virtual Weekend

leave a comment »

I have had VMWare Player installed for a little while now and have been getting acquainted with some of the Community built images – especially Ubuntu. Yesterday, I decided to be upgrade my Ubuntu image to 6.06 (Dapper Drake.) So, I copied the 5.10 image, renamed it all to 6.0 (remembering to rename all the references in the vmx file), gritted my teeth and upgraded (change the sources file and do an ‘apt-get dist-upgrade’). OK, so I didn’t need to grit my teeth – it mostly worked and where it went didn’t go according to plan, the action suggested sorted it all out.
A couple of hours later (most of which I spent out of the house) and I was the proud user of Dapper Drake. And very nice it is too. The main reason I wanted to upgrade was to get version 0.9 of MonoDevelop, which I now have, so I can start to monkey around. I haven’t had too much time yet with MonoDevelop but the good news with this version is that the ‘Import Visual Studio Solution’ option works (so farewell to prj2make#.)

Written by remark

April 9, 2006 at 8:01 pm

Posted in General, Open Source, Ubuntu