Blog | RSS | Photo Gallery | Wish List     Eric's Blob
Hubris is Dead. Durn! Posted at 20:34 by Eric
False laziness and false impatience strike back. Hubris falls over dead! Well, darned if I didn't just forget everything I ever knew about the three virtues of a programmer (laziness, impatience, and hubris). Further, the number one thing I've been studying lately, design, just went out the window.

The book entitled "The Pragmatic Programmer discusses a concept called broken windows. Apparently, in New York, it is illegal to have a home with a broken window. It actually encourages others, if a window breaks, to leave it that way. Suddenly, all sorts of people have broken windows. But it gets worse. Now that things appear to be really run down, graffiti begins to appear. And then crime rises in that same area. All because of a broken window.

I actually built a house from the ground up, complete with broken windows. I allowed pressure to get things done affect my judgement as to how I should develop a piece of software. I was given a project that I thought would take 2-3 weeks to complete. No big thing. But throughout the whole process, I was frequently told that this needed to be done quickly, as quick as possible.

So, I fired up my text editor, and started banging out code to get the job done. Neither Perl nor Vim were at fault here. Several mistakes stand out:
  • Code Seperation
    Although I had a variety of functionality, I stuck it all in the same file. I had the perfect opportunity to create seperate modules at this point, allowing for quick usage in the future. It's quite certain that this functionality will need to be reused in the near future in another project.

  • Logging/Debugging
    Anyone who uses print or warn statements for debugging is making life unnecessarily hard on themselves. There is an excellent module available to Perl programmers called Log::Log4perl. Using a config file, you define what the log level should be at. So certain things will print out during debug mode, and (hopefully) less would print out during normal execution while in production. You can even do things differently based on if you are in debug mode or not. But I skipped out on all these features. No, my code is full of... stricken with.. warn and print statements. I'll have to manually remove each one when this code goes into production.

  • Config File
    There are a variety of options set within the program. Now, it was done reasonably well within the code. They were not hard coded where it was used, they are all config variables defined at "sensible" locations. However, it was insensible of me to do this in the first place. These options shouldn't be defined within the program. This stuff should be easily configurable via a simple text-based config file. Now, if I want to change any of this, I have to open up the code, and risk breaking it in order to change variables within it.

The fact is, it's going to take me longer on this project to move from development to production because of all this, that it would have taken if I coded it right to begin with. It's really not all that hard to do the above. But I got a false sense of security in that if I hurry through everything, I can see things working quicker, and I can show that off to those looking over my shoulder asking for results. On a project this small, by just waiting a few more days before showing off any features, I could have it coded right the first time.

I believe that no matter which way it was coded, it will go into production at the same time. The poor way simply front-loads the visible features. Not included in the time estimates above is the fact that I'm going to go ahead and refactor it to make it right. I'll seperate different functionality into modules, I'll create a config file(s), and I'll use Log4perl to do logging and debugging.

I hope to learn from this experience. First, I am eager to fix all the above, and to see how it looks when done properly. Second, I look forward to being able to start another project, and to do it right from the ground up. What disturbs me is that I know all this, and I do it well when I want to. So the learning experience here is to decide to do it, each time.
| |

Post a Comment
    Name:
    URL/Email: [http://... or mailto:you@wherever] (optional)
    Title: (optional)
    Comments:
      Use HTML for formatting. Allowed HTML: <a> <p> <b> <i> <u> <hr> <br> <ol> <ul> <li>

trackback

TrackBack ping me at:

http://www.openthought.org/blosxom.cgi/Blog/Computers/Programming/Perl/hubris_dead.trackback