Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jest (4401)

jest
  {jester} {at} {panix.com}

Largely unskilled but enthusiastic JAPH. In my other life I hack the Oxford English Dictionary.

Journal of jest (4401)

Wednesday October 29, 2003
02:19 PM

Refactoring the Wheel

[ #15455 ]

Perhaps a year ago, I wrote some programs to deal with running a library database. The application worked nicely, but the programs were terrible--huge chunks of repeated, unmaintainable code.

A number of months ago, I learned a lot more about OO Perl, and went through a big refactoring binge and stuffed lots of things in modules.

A smaller number of months ago, I learned even more about OO Perl, and fixed some of the infelicities of the code.

A few days ago, I greatly generalized the code, so I can use the same modules to handle other databases I work with. This refactoring pass went very smoothly, and I felt confident. In the process I realized that one big chunk of the code is still appallingly bad; I spent a huge amount of effort on this elaborate solution to a problem that could have been solved much more easily if I had just used some templating system. (I had set up complicated modules to generate and process forms in a particular way.) So now I realize I have to go through and refactor this entire chunk to use TT or something, which will be non-trivial due to the complexity of the existing code.

When I'm finished with this, I will be in exactly the same place as over a year ago. I mean, I'll be a better programmer, and know a lot more, but this code has been in production use the whole time and no one knows I've done anything at all.

I suppose this is a good thing. But I'd like to throw in something neat, that I couldn't have done a year ago, or something.

</meditation>

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • When I'm finished with this, I will be in exactly the same place as over a year ago. I mean, I'll be a better programmer, and know a lot more, but this code has been in production use the whole time and no one knows I've done anything at all.

    You've actually accomplished something great, then. The code will be much more maintainable. I'd see lines of code eliminated as a good metric of how much you've simplified the system.

    Throwing code out is liberating. Gets rid of bugs, too.

    I suppose this is a

    --
    J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
    • You've actually accomplished something great, then. The code will be much more maintainable. I'd see lines of code eliminated as a good metric of how much you've simplified the system.

      There's a scene in Revenge of the Nerds, where someone from Microsoft (I think it was Steve Ballmer) talks about what it was like working with IBM on OS/2.

      The IBM developers were stodgy old mainframe types, who were very regimented, hierarchical and by-the-book. The developers Microsoft contributed to the project wer

  • Refactoring is a hard sell with a program that works and doesn't need to be updated. As programmers, we deal with writing code (and debugging it, of course), so our focus is on projects that need work. We tend to ignore projects that are "complete" and don't need additional labor.

    Cringely picked up on this [pbs.org] a few months back. When it comes to working bodies of code, going back and refactoring something stable is a waste of time. But Cringley's ideas of an army of helpful Refactoring Gnomes is specious,

  • If you did all that internals work and nobody noticed.

    Usually, when I do major rewrites, bugs and problems inevitably turn up. It shows that you worked deliberately and carefully and tested well.

    Congratulations!

    And remember, it's the journey (becoming a better programmer) and not the destination (source code) that is all the fun.