Forensic Development
A while ago a friend and I coined a term for what we end up doing most of the time when we get a new development gig. We usually have to go in and figure out someone elses code. Sometimes it’s legacy code that has been chugging along since the Regan administration and suddenly stopped working. Other times we’re called upon to upsize an Access database created by an administrative assisitant in their spare time. Mostly what we’re doing is either exploratory surgery on a codebase or, more likely, an autopsy. The only difference is we’re expected to pull a Doc Frankenstein and put all the parts and pieces back together into a living application.
Here’s the description I submitted for my Portalnd Code Camp presentation.
Have you ever been given an application and told to “make it work”? Have you ever had to extend an off the shelf application? During my forensic development presentation I’ll talk about some ways to find out what the code you are suddenly responsible for is actually doing. I’ll cover investigative methods and ways to tame old code as well as ways you can leave behind clues for the next developer. I hope to stimulate a short discussion about when it is appropriate to start over rather than hack away at a codebase.
So here’s what I’d like anyone reading this to do. Submit your best “I figured out what the heck this code was doing” story. Your best “Eureka!” moments while debugging or the most obscure error you’ve found. I don’t care what language or platform you used. Tell me about some of your favorite techniques. Places you look for errors first and last. Ways that you use to make the computer tell you what is really going on.
Scoble is looking for names for Longhorn
Let’s get Longhorn’s inadequacies out of our systems
Robert wants us to come up with creative names for Longhorn. My favorite is still “shorthorn”.
But honestly, calling Longhorn names and making fun of Microsoft for being so late and so lame is a little like booing at the Special Olympics.
When to not log exceptions to the event log
Raymond Lewallen : Logging exceptions in your event log
(Via Raymond Lewallen.)
Raymond has a short post showing how to log exceptions to the server event log. I’ve had this bite me in the butt a couple of times. Mostly when my app has been deployed to a cluster.
We have a situation here where our applications are deployed to a seven node cluster with “sticky sessions”. That means that whenever an exception is written to the event log, it’s written to the event log of the server it happened on. That means I have to view the event log for each node in the cluster until I find the one that had the particular exception at the exact time I’m looking for. That’s IF the event log is set to clear itself or is being maintained by the sys admins.
Another problem with the event log is that it isn’t queryable. Well you can query the event log, but it’s a pain and it’s not as flexible as an RDBMS based exception log.
I usually either end up rolling my own error logger, or finding one that works with whatever technology I’m using at the time. I’d list them all here, but there are too many for me to type out. Just Google (or Yahoo or MSN) for “error logger” for whatever technology you are using.
half moved over
Well I’ve moved 1/2 of my sites to the new web host. I chose WebHost4Life. So far, there have been a few bumps but their support has been very responsive. Picking this new host means I’ve moved from Apache to IIS. Which means my URL rewrites quit working.
I’ve set up some redirectors so if you’ve subscribed to one of my feeds you should get a 301 and be sent to the new site. I’m looking to see if there some way I can do the redirections using an HttpModule in ASP.NET, but it looks like I’d have to parse the incoming URL, then create a WebRequest to the correct PHP page and send the request string to the HttpWriter. That spells S-L-O-W. Caching would help, but it seems like a lot of extra work. I think my 404 redirector will work, it seems to have worked for the few pages I’ve googled.
One interesting side effect of this is that I’ll be able to post some of my ASP.NET controls on a demo page. I made the move primarily due to a price/space issue, but posting ASP.NET apps and PHP apps side-by-side is an added bonus. The only way it could get better would be if I could deploy Rails applications. Anyone from Webhost4Life reading this? Any plans to let us deploy Rails applications?
I’m planning on setting up a test server at my house anyway, I’ll be able to set up some sub-domains for my little play applications.
Ruby for Java and C# developers
Ruby For Java (and C#) Programmers, Part 1 – Conventions, methods, modules, and classes
Ruby For Java (and C#) Programmers, Part 2 – Operators, methods, and more on classes
(Via Tucows.)
Looks like a great series. I like the comparisons between Java and Ruby.
Forensic Development
Debugging Detective Stories: Phill Haack
(Via Scott Hanselman.)
Phil has touched on something that I plan on Presenting at the Portland Code Camp. What my friend Brian and I call “Forensic Development”.
I’ve been writing code for about 10 years or so now and I think in that time I’ve written four applications from scratch. I’ve spent most of my time in the IDE, SQL Profiler, digging around in server logs, examining cookies on user machines, trying to figure out why this 5 year old application has stopped running or what the heck the last guy to touch the code was thinking. My other favorite is when someone decides that it would be easier for you to modify an existing off shelf application (or an OSS app) than it would be for you to write one from scratch. That is almost always untrue.
Here’s my original pitch to the Code Camp Yahoo group. If you’re in the Pac NW, be sure to sign up for the Yahoo group and come down. It’ll be a blast and “if you’re not careful you might learn something before you’re done…hey hey hey.”
“There’s always some old
application that’s been around for ever that someone
wants to add a new form to or print from. Or there’s
some software package that the IT dept purchased but
it doesn’t QUITE do everything they want so they
figure “Hey, you can just modify this right? All we
want to do is change this one thing, that’s easier
than writing it from scratch right?”. Which means that
you have to try and get inside this other developers
head and figure out how the app all fits together.
Where it’s “pain points” are and how to deal with
them.Sometimes the old apps just stop working. Next thing
you know, you’re pouring over Apache logs or SQL
T-logs and event logs trying to figure out
a) when it died
b) what it was doing when it died.
c) How to get it running again before everyone gets
back from lunch and your phone starts ringing.In a lot of ways, working on legacy code is a like
being a CSI. You might not have access to the source
code and somebody might have obfuscated the public
methods. So you start passing in random things and
looking for your arguments in the output.
“
Which reminds me, I need to write up a short blurb for the presentation.
