Tuesday, April 22, 2008

AAArrrggghhh Legacy Code

Recently, I've been working on what is probably the "Ultimate" legacy/Brownfield application. It's a VERY important application for our business, or WAS, but the users are starting to find other ways to do their job. The problem is that the application in question is VERY hard to maintain, and management does not want to risk making any "non critical" changes. It's the classic "Big Ball of Mud" design.

Now no matter HOW many time's I've read Michael Feather's Working Effectively with Legacy Code, I can can never quite figure out how to make it work in this case. There are almost no seams to exploit. We have numerious routines that have a Maintenance Complexity in the 2000 to 3000 range. Of course these routines have no REASON to be that complex, it's just that previous programmers had a tendency to lump all sorts of things together that had nothing in common except that they needed to execute at the same time.

DRY? They never heard of it
The classes are just mirrors of database tables, and if a calculation needs to be done on a class or collection, the routine is usually inline in a form event, with "other" code mixed in.

I do find RefactorPro! to be a very useful tool, but even with automated tools, I have to take huge risks, just to get the code to the point I can start putting test harnesses on it.

Anyone else have to maintain a probram like this? The goal here is to get the application maintainable enough that I can start to add features to retain/regain our internal user base

Friday, April 18, 2008


About 15 years ago, Mary and I went on vacation to New Mexico, and stayed at a place called Starhill Inn. It was the BEST vacation we ever went on. We always said that when the kids got old enough, we would go back. Last week, we decided "This summer is the time"

I just called them. They are closing June 30th. No more Starhill Inn. I'm seriously bummed. I was REALLY looking forward to it.

Oh well. Now comes the question. Do we want it to be a "Northeastern New Mexico" Vacation, or an "Astronomy" vacation? Any readers have any good ideas?

Wednesday, April 16, 2008

Vista SP1 out..

I see that Vista SP1 is offically out. I guess all those folks who said "I'll wait until SP1 to try it" can now go out and well, Try it.

Want MY Honest opinion of Vista? By now, you've probably seen my posts. I LIKE Vista, BUT you have to do things "The Vista Way". If you try and do things the "XP Way" you will often end up in a "Boy is Vista Annoying" mode.

BTW It turns out Vista was designed to be annoying to try and force small software vendors to change their software to work with Vista. That backfired on Microsoft, and folks complain about Vista instead of the small programs. I think this is because > 50% of the small vendor programs become 'naggy', and people blame Vista instead of the program running under Vista - fair enough. I won't go into the reason WHY Microsoft wants these changes (see previous posts), but...

Tuesday, April 15, 2008

A Basic Class Design Lesson

Hi Gang,
I'm going through some OLD code today, probably written before classes, but looking at it, I realized it might be a good class design lesson for those not used to writing classes.

The code was in a form, and was actually used multiple times - which by itself says the code should be in a function - code has been changed slightly to obscure the exact nature for my blog, and is in Visual Basic 6.0, but the lesson works for any Object based language

If Left(instanceOfClass.pollclose, 2) > 12 Then
objGrid.Text = (CInt(Left(instanceOfClass.closingTime, 2)) - 12) & ":" & Right(instanceOfClass.closingTime, 2)
objGrid.Text = Left(instanceOfClass.closingTime, 2) & ":" & Right(instanceOfClass.closingTime, 2)
End If

OK (again, VB6 syntax) you could say:

Private Function formatClosingTime(byval theTime as string) as string
If Left(theTime, 2) > 12 Then
formatClosingTime = (CInt(Left(theTime, 2)) - 12) & ":" & Right(theTime, 2)
formatClosingTime = Left(theTime, 2) & ":" & Right(theTime, 2)
End If
end Function

and put that in the form

Which would make the call in the form

objGrid.Text = formatClosingTime(instanceOfClass.closingTime)

- it's ok, and a heck of a LOT better than it was (remember, it's used multiple places - the Don't Repeat Yourself (DRY) concept comes in here)

BUT - that's NOT where the function should really be. What we do is add a Property to the class

Public Function formattedClosingTime() as string
If Left(me.closingTime, 2) > 12 Then
formattedClosingTime = (CInt(Left(me.closingTime, 2)) - 12) & ":" & Right(me.closingTime, 2)
formattedClosingTime = Left(me.closingTime, 2) & ":" & Right(me.closingTime, 2)
End If
End Function

Now, this reduces the code in the form to:

objGrid.Text = instanceOfClass.formattedClosingTime

Isn't that better? The class is taking care of itself. Ahhhh

Thursday, April 10, 2008

Agile/XP programming and the OODA loop

Today, over at Inc.Com, Joel Spolsky of Pragmatic Programmer had an article called Fire and Motion, where he talks about getting your competition responding to YOU. It's a really good post that I think you should read.

When I was reading it, I was reminded of

John Boyd's OODA Loop, and all of a sudden, I realized WHY Agile/XP works. It's NOT the Agile Manifesto. It's NOT Pair Programming, or any of the OTHER tools. Agile/XP is a Tool to speed up your development teams OODA loop massively. One of the tenants of the OODA loop is that a GOOD decision, quickly implemented, beats a PERFECT solution delivered later.

Let's think of what XP/Agile has you do - Short iterations. Observe at what the client needs, and quickly fill that need. Not necessarily with a perfect answer, but something. Then ask the client "OK, Now decide how it needs to change", and then add that. Quick loops

Why I never thought of Agile/XP in terms of OODA before, I don't know, but it was a light bulb going off

Tuesday, April 08, 2008

How to Compress Virtual PC Hard Disks

As more and more of us use Virtual Hard Drives to test/develop different software, here is a great HowTo: Compress Virtual PC Virtual Hard Disks over at Kurt Shintaku's Blog - HT to Kirk Allen Evans - via Jason Haley

Tuesday, April 01, 2008

ALT.NET Leadership to suppliment the traditional .NET leadership

Jeremy Miller has (as usual) and interesting post on The need ALT.NET to supplement the traditional >NET leadership

I can't agree more. Right now, I think some of the best REAL WORLD developemnt stuff is coming out of ALT.NET. It seems Microsoft IS listening to a point (Unit tests in VS2008 etc) but...