Posts

I've been away, but now I'm back

Apologies for the lack of updates. Not that I expect anyone is actually reading such an ill-kempt blog. I have been spectacularly busy both at work and at home. However over the following weeks I will be attempting to catch up with a few technical bits and pieces which I have been meaning to share with the world. Lastly, but most importantly, I am sorry to announce the passing on of the original mono-rail cat. Whitby died peacefully in her sleep, in her favourite spot (the hot water pipe which runs under the bathroom) a few months ago now. My wife misses her more than I do. RIP.

Raw Sushi

Image
Some raw sushi that I made today. Parsnip Rice Wasabi Aioli on the top It was delicious!

Learning to code

OK, Interesting conversation with another "developer" - in the loosest sense of the word, regarding a mutual friend who is just starting to learn C# I mentioned that the world would be a nicer place to be if all developers were given a grounding in things such as: - Source Control - Design Patterns - Unit Testing Before being let loose on the world of code. The question is, should your first "hello world" application be unit tested? Developed using TDD? Adhere to the MVC pattern? Be in source control and properly labelled? I think the answer is a pretty resounding "yes, of course". The reams and reams of substandard C# I see every week (mainly from code posted on the interweb) demonstrates the fact that people don't "pick up those things later on". They simply don't. How many code/function snippets have you seen on various blogs (mine included) which have associated unit tests? Hardly any. Don't get me wrong, I'm as guilty of ...

NDepend and Cruise Control .Net

Well, it had to happen, I finally got around to posting my fix/hack/dirty for this problem. 1. The problem: NDepend html results are very pretty, but don't work when you integrate NDepend into CC.Net, CC.Net's own xslt log parsers mean that the pretty images created by NDepend (dependency diagrams, Zone diagram, etc) are not shown. 2. The fix! Create new file called image.ashx (ashx = cut-down webpage without the tedious events wired up) Stick this in there: <%@ webhandler language="C#" class="ImageHandler" %> using System; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Drawing.Imaging; using System.Globalization; using System.IO; using System.Net; using System.Web; using System.Web.Caching; public class ImageHandler : IHttpHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext ctx) { try { string name = ctx.Request.QueryString["name...

Non-cursor cursors

So I've been doing SQL queries for a while now, but only just worked out that 99 times out of 100, whenever you think you need a cursor, you probably don't. You probably need some sort of loop and some sort of track of where you are...but the answer to that is NOT a cursor. For example: You have a list of portfolios that you wish to value, but you need to call a proc/function against each in turn, so doing a single query is out of the question. The answer would appear to be a cursor, iterating over a list. WRONG. Here's how NOT to do it: DECLARE pfo_cursor CURSOR FOR SELECT pfo FROM #id OPEN pfo_cursor FETCH NEXT FROM pfo_cursor INTO @pfoLoop WHILE @@FETCH_STATUS = 0 ...do stuff with @pfoLoop FETCH NEXT FROM pfo_cursor INTO @pfoLoop CLOSE DEALLOCATE And here's a quicker, easier, cheaper, better way: SET @pfoLoop = (SELECT TOP 1 pfo FROM #id ORDER BY pfo) WHILE @pfoLoop is not null BEGIN ...do stuff with @pfoLoop SET @pfoLoop = (...

Pfaffikon and Chicago

Image
Apologies for the lack of recent updates. My work-life has taken a turn for the better recently, with several business trips abroad working on a new Scrum with the potential to deliver even more business benefit, quicker. To that end, I've been working with some guys in Switzerland, and for the last two weeks have been working with some guys in Chicago. I would have added a picture of Pfaffikon, but it's mainly populated by farms and coos, so not very picturesque. So, that was the first time I'd been to the USA for about 20 years or so, and I have a number of things to report: 1. The adverts for prescription drugs ...are hilarious. 20 seconds of details about the drug, then a full minute on its side-effect; may cause Coma, Low blood pressure, High blood pressure, hair-loss, weight-gain, hair-gain, weight-gain, blurred vision, cataracts, nausea and death. If you die whilst taking this, please contact your GP. Best advert award "Extenze", which is a sort of Viag...

Code Coverage

Today I have been mostly OBSESSED by upping my unit test code coverage. When I inherited this current codebase all the way back in August 2008, the code coverage was 0%, nothing, nada. No unit tests and the code was in a right 2 and 8, and no mistake. It's taken a LONG time and a lot of effort (and a lot of referring to my Design Patterns books, GOF and HeadFirst, both highly recommended, even if the examples in both are in Java rather than a proper language) - but I'm there, today I hit 93.7% with the remainder of the code being reasonably un-unit-testable (mainly in the datalayer, where no amount of fiddling will let me properly mock out OleDb connections...) I have started work on a "Refactor to Abstract Factory" method - which I intend to demonstrate at the next "Show and Tell", just to bore the life out of the Product Owners when they ask "so what have you delivered this month?". The upshot of this is that the codebase is now fit for...