http://www.perlmonks.org?node_id=614246


in reply to Programming *is* much more than "just writing code".

Very well said. Thank you for the time you put into it.

And most especially, thank you for saying something that needs to be said over and over again until everyone in the universe understands it: Programmers should not expect to be able to open a source file at random, move to some arbitrary point within that file and then instantly be able to modify the code there from just a cursory glance at the code and comments in the locality.

I cannot tell you how many times I've heard "This program worked fine until the last time we had it modified by our usual programmer, and ever since it works fine most of the time but every now and then doesn't work at all". It's always always always because their "usual programmer" modified the thing without bothering to gain sufficient understanding of the program as a whole entity.

When I hear that story from a potential new client, I won't even look at the code until I'm on the clock. Too often, that other guy in whom they've lost confidence has been given one last chance and is out there feverishly kludging together yet another bandaid pseudofix. His desperation will always move faster than my diligence.

Replies are listed 'Best First'.
Re^2: Programming *is* much more than "just writing code".
by Rhandom (Curate) on May 08, 2007 at 20:53 UTC
    I cannot tell you how many times I've heard "This program worked fine until the last time we had it modified by our usual programmer, and ever since it works fine most of the time but every now and then doesn't work at all"

    My usual follow up to conversations like these is something like: "Good thing you now have extensive unit tests around your code. You do have unit tests around your code right?"

    Any recent system I've worked on has a test suite. "I" understand the code "I" have written and "I" have broken the code when "I" though "I" knew what "I" was doing. Commenting or not has little to do with the situation. It is good that I've had revision control and unit tests to figure out what I broke, how to fix it, and how to check that everything still works.

    That really should be done in maintenance mode as well - find all of the existing use cases, wrap them up in a unit test file. Make sure that test file works as you progress in your changes.

    Oh - and be sure to leave a comment for why you chose the new algorithm that you implemented. :)

    my @a=qw(random brilliant braindead); print $a[rand(@a)];
      It's not often that I consent to inherit someone else's problem code, but when I do there's an economic reality to be considered. If the client's cap is at four hours of labor (billed), I'm not going to spend 40 hours writing tests. I don't provide charity to commercial enterprises aside from that extorted by the IRS to be doled out as corporate welfare.

      I always comment non-obvious design decisions, by the way. Those are comments that might actually be useful to the competent maintenance programmer who's been tasked with refactoring my code. I frequently include URI's for in-depth discussions of the algorithms that might not be known to programmers at large. If I've optimized the code, I'll frequently include benchmark results to show that the code has been optimized at the right point in the development cycle. But I'm not going to take on the role of educator to explain to a maintenance programmer why I've chosen to implement a database connection as a singleton, or memoized a recursive method that can benefit from it. He already knows why, or can do his own homework, or can take the job he's best suited for down at the car wash. I can't save the code or the client from him and it's not my job.

      While I value good code and sound professional practices, I'm really not going to lose any sleep over what happens two years down the road when some cheap client hands my code over to some high school kid who's only worked through the first four chapters of Learning Perl. Not my problem, not my job. If I'm for some reason deemed not quite good enough to do the work, then that squeaky voiced kid who calls to ask "Yo, Gee, w'sup widdis singleton shizit?" had darn well better be. He dialed the wrong number and is on his own.