Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Maintenance vs. Programming style

by talexb (Chancellor)
on Jan 29, 2008 at 17:42 UTC ( [id://664932]=note: print w/replies, xml ) Need Help??


in reply to Maintenance vs. Programming style

    When you need to enhance or debug code written by someone else, do you restrict yourself to the minimal change? Or do you find yourself cleaning up code, making it look more the way you program?

That depends. Do you want to get in and get out, or are you going to turn this into a career?

    I've inherited code written by someone who wrote verbosely. I keep finding myself saying "I could make this so much smaller, so much more efficient".

Sure. And are there exhaustive tests that you can run to verify that your "cosmetic" changes don't make any of the tests fail? And what's the risk?

    Mind you, verbose programming can be very useful, especially in an environment where you don't know who may end up supporting your software. Dense programming could cause more problems, and would require extensive retesting.

I have a confession to make. My code is usually pretty terse, but I suffer from over-commenting. So I'll write something brief, then spend the next five lines explaining what I just did (or what I'm about to do, since I put comments ahead of the code).

I'm just terrified of coming back to my own code in six months to a year's time and being unable to grok what it's doing.

    Regardless of that, I'm curious: Do you give in to the temptation to make someone elses code look more like yours, or do you successfully resist it?

Nope -- I get in, make the smallest possible change, look over it *very* carefully, do as much testing as possible, and get out. I don't even muck with the indentation.

You've heard the phrase "The road to hell is paved with good intentions"? Many of those good intentions are a variation on "But I only made a small change to the code! It shouldn't have changed anything!"

Great question.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://664932]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-28 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found