Monday, October 09, 2006 - Posts

For an ego boost, read your old code

I recently resurrected an application I wrote for a college project a couple of years ago.  As I'm going through this code, I found a number of areas that needed some improvement.  Not major meltdowns or security holes, mind you, but there were several places where I had unnecessarily written duplicate code, inconsistent naming standards, outdated comments, and at least one failure to explicitly close a database connection.  In one case, I was actually creating a connection in three different functions to call the same stored procedure (from the codebehind page, not even in a data provider class!).  A quick trip through the database structure found several tables that needed additional indexes for performance.

Though it was hard for me to believe that I could make such obvious mistakes, I actually looked at this discovery as a positive.  This code proved to me how much I have learned in just two short years.  Even though the application works well as-is (and got me an A in the class :), its shortcomings are proof that practice makes perfect.

So, if you're looking for a quick pick-me-up, dig up some old code you wrote and critique it.  Moving forward, make it a point to save samples of your code over the years, to go back and pick apart later.  You'll be glad you did.