Too scared to add code, replaced by too much work to add code?

I don’t think many people will disagree with the practice of adding unit tests and striving for 100% code coverage. However, I think there is a very real downside to it. It wasn’t so long ago that I was faced with making a change to some code that had zero unit tests and a fair amount of coupling. I hated making that change and it was the coding equivalent to treading on egg-shells. After a period of refactoring and creating unit tests the story is better…or is it? I no longer have such a fear when it comes to changing that code, I know that even if I don’t find the correct unit test to run the continuous integration process will run it and complain if there is a problem. However, I am now faced with a different dilemma, every code block I add I need to create a unit test for it. There is no escaping the fact that it does take some extra time to write the tests and it does impact on the here and now. Of course I will write them because it will be better in the long run but my real fear is that you start to code differently because subconsciously you start to avoid doing things that require you to write extra tests. Consider this very simple example of checking an age…

totalAges = newAge + currentTotal

Now really I should throw a specific exception if the age is negative…
if newAge < 0 then throw new AgeNotValidException
but if I do that I’ll need to write another unit test to ensure that this exception is raised. The little devil on my shoulder says, "but that’s not likely to happen is it, no need to do that, it’s not in the specification, why add it, look at all the other code you’ve yet to write, etc, etc". It is a matter of pride in your work and ultimately you should always do the right thing, but I can’t help feeling this is like red-tape. I wonder how much Test Driven Development dynamic language developers will use?

Silverlight keyboard part 4

Well the use of the off-line keyboard map seems very positive via ToUnicodeEx. It took me ages to realise that I’d got the Virtual Key and Scan Code values the wrong way around (doh!). I hardly spent any time on it, but my final test correctly displayed an accent from the Virtual Key of Tilde. Given that ToUnicodeEx takes a keyboard layout (or was it locale?) as a parameter then I’m confident this should at least provide fair stab at a decent keyboard translator.

Canon 350D slant or tilt problem

A problem I seem to be having with my Canon 350D is every now and then I get a nasty tilting, esp. with landscape shots. So this picture was taken by carefully lining the horiz’ focus points with the horizon line. See for yourself what happened…
 
 

Comparing Cameras

I’m trying to learn how to use my Canon 350D to get decent shots but I’m finding it difficult. As a comparison I’ve got two shots of (almost) the same scene at the same time, one is from the Canon 350D, the other from my pocket Sony, any comments as to which you prefer and why the Canon one is worse (guess my favourite) then please say…
[EDIT] The upload process has destroyed the size of the images, I’m looking for another host now…
 
350D –
Camera Model Canon EOS 350D DIGITAL
Shooting Mode A-DEP
Tv( Shutter Speed ) 1/800
Av( Aperture Value ) 3.5
Metering Mode Evaluative Metering
Exposure Compensation 0
ISO Speed 100
Lens 18.0 – 55.0 mm
Focal Length 21.0 mm
Image Size 3456×2304
Image Quality RAW
Flash Off
White Balance Mode Auto
AF Mode One-Shot AF
Parameters Settings Contrast  Mid. High
 Sharpness  Mid. High
 Color saturation  Mid. High
 Color tone    0
Color Space sRGB
Noise Reduction Off
File Size 6976 KB
Drive Mode Single-frame shooting
Sony –
Camera Model Name DSC-T100
Tv (Shutter Speed) 1/640
Av (Aperture Value) 4.5
Exposure Compensation 0
ISO Speed 125
Image Size 2592×1944
Flash On
Color Space sRGB
File Size 1295 KB

McAfee & SMTP, and are Virus Checkers the worst form of Virus?

Yesterday I was asked, "the application isn’t sending out emails, what is wrong?" The simple answer was, "you’ve installed McAfee Antivirus". The default installation this AV is to block the SMTP port, nice.

I’d like someone to do an impartial review of modern "protection" software. I recently read a review in MacUser about the hype of threats and I’m beginning to come around to their point of view. It’s not that I don’t see the value of such monitors but in my experience this particular tool seems almost as bad as the threats it reports to stop, I’ll explain why. What is the threat of a virus? Well there are many privacy related issues but for a modern company behind a hardware firewall I believe the two main risks are; Trojans and denial of service (DoS), both often resulting in a large amount of downtime to repair.  A Trojan is a risk as it could send important details to a basic HTTP site and could be very damaging, so I want my OS/Virus checker to stop things changing/installing executables (DLLs, scripts, et al) without my permission. DoS – where naughty software is doing something for its own gain (spamming) or just bringing a system to its knees for "fun". For DoS I want my OS/Virus checker to stop things changing/installing executables (DLLs, scripts, et al) without my permission, sounds familiar. Modern virus checkers do this so what is my issue? I wouldn’t have one if that is all they did. No they go the extra mile, they turn off useful ports (see SMTP above) without asking me, they inject script to help ensure scripts I run are ok (and those scripts then cause failures), they double check every file that is read (yes read as well as write). Not only that but one version (the one with lots of yellow) they can install loads of odd software and services I didn’t and don’t want – but can I get rid of the sub parts, nope.  Essentially the modern Virus Checker is one of the slickest DoS and Trojan installer you’re willing buy and install. DoS from a virus checker is no laughing matter. I regularly compile large projects and you can easily see the significant difference in speed with the checker on and off. So if I was to add up all the time lost in these minor DoS attacks from the checker against the number of infections * time to rebuild PC/PCs infected I wonder which would be worse? Now it doesn’t have to be as black/white as that. As I’ve said, if my checker simply attempted to stop nasty code getting on my machine then I’m pretty certain I would have a machine that does its day-to-day tasks efficiently with a very small chance of having nasty code installed.

I guess the moral of this story is choose your AV software carefully, consider what you deem to be an acceptable threat and learn the mantra, "options exclusion is your friend, options exclusion is your friend".
 

ITunes anger re: DRM

I’ve recently created a dual boot system of XP and Vista and made my first purchase from iTunes, I downloaded the Ricky Gervais pod casts series 2. It didn’t go well, I paid the money but the download failed half way through but eventually I managed to get the full audiobook. I put said download on my iPod and enjoyed the crazy brain of Carl, all this using XP. So last night I installed iTunes on Vista and downloaded series 3. Dragged the download onto my iPod and got, "you are not authorized" or some such message. To say I was angry was probably an understatement. I dragged the files into a shared (XP & Visa) drive and rebooted into XP, where I happily copied the files over. So this morning I thought I’d revisit Vista. When I double-clicked the download in iTunes it said I wasn’t authorized BUT it then offered me the chance to authorize this machine which I took. So…a) why didn’t I get that chance in the first place b) why doesn’t it recognize the "machine" rather than the OS c) why bother when it knows I’ve purchased it!? I hate DRM, everyone that pirates audio/dvd etc will always find a way and poor paying saps like me get the worst experience ever…I still get very angry with the seeming 1 hour anti-piracy intro’s on DVDs. So please entertainment industry ditch this stupid DRM concept and stop telling me not to pirate the film I just bought/rented.
 
 

3D ALT-TAB in Vista

I realise that I’m probably the only person in the World who didn’t know how to do this, but just in case ;)…
 
Every time I see a demo of Vista they use a 3D version of ALT-TAB to cycle through the open windows. After installing Vista my ALT-TAB would only give a very useful but non-flashy thumbnail version of the applications. The trick is to use START-TAB rather than ALT-TAB, http://www.microsoft.com/windows/products/windowsvista/features/details/flip3D.mspx
 

Funny seminar title

I was looking at an XP seminar in London and the following raised a smile…

Programmers maybe from Mars, Customers maybe from Venus, but Why does everyone think that Project Managers are from Uranus?
Clarke Ching

 

Silverlight keyboard input, an alternative

As you may know I’ve been tring to get Silverlight to accept keyboard input and was talking to a couple of Microsoft guys today at an MSDN Silverlight roadshow. The sent me over to the demo site http://www.tafiti.com/. "Ah but will it take odd keys" I asked smugly. He tried it and it did, hmm. So as soon as I got home I opened the site to look for myself. Immediately I spotted what they had done. If you click in the input box and then resize the browser window you’ll see it too! They’ve repositioned a HTML input box into a white silverlight rendered box. Ok so it’s a nice workaround but it isn’t really solving the problem, but I thought I’d blog about it as an alternative solution.

Silverlight keyboard part 3 (sort of)

Nearly all bad news trying to get this to work correctly, seems I’m not alone either. However I started to poke around in the windows libraries and found MapVirtualKey. After PInvoking it and getting yet another key code that seems unrelated to my keyboard I did a swift search and found this blog, http://blogs.msdn.com/michkap/archive/2006/03/24/559169.aspx. Aha, this looks like it could be good. So the plan is to digest this blog and provide a mapping service based upon the keyboard. The weak link would be the keyboard support/layouts installed on the server but hopefully it will catch the majority of cases, if not could provide some form of downloadable component that you can use to interegate your keyboard and upload the mappings. This would be Windows only or at least MONO.