Poor mans revision control vs. Stupid mans revision control

jonasbn on 2008-01-28T10:16:10

I am sick and tired of reading code where large sections are commented out, this mean I have to skip large sets of lines and this disturbs my reading of the code.

An even worse practice is when the entry points are renamed. Like subs are renamed to dostuff2 or dostuffold and dostuff is the one currently used.

The later probably being one of the worst, I have seen some of these in XSL style sheets where the match tag id disabled so it does not correspond with your XML. So the code is not really commented out, it is just never entered, very misleading.

I call this stupid mans revision control.

Comments in code are nice and sometimes you comment out something for debugging or disable a feature, even in production, since this is simply faster, we know it is the right way, but we do it anyway.

The problem with the last practice is that you overwrite everything also these small fixes when you deploy the next release. So I will argue that if you find it necessary to apply such fixes in your production code and you can not propagate the fix back into your SCM you need to work on your setup one way or the other. Your SCM should at all times be the sole place of reference.

Yes, CVS and SVN and all of these might not be the answer to all your problems but if you work around them they are not really put to use and instead they become a poor man's backup tool instead of a poor mans revision control.

I am no SCM superman, but I force myself to use SCMs and learn new stuff all the time, it is uphill sometimes and I make the same mistakes over and over again (me and CVS import will never ever become friends), but I insist on using SCM and getting the tools to work for me instead of having them becoming a tedious part of doing development.


Ah yes:

Aristotle on 2008-01-28T10:48:44

In the extreme, this is called a developmestuction environment.

It is the most horrible habit ever – the most horrible possible habit.

Dare to delete, people! Does the code need to be there? Really? If it’s not absolutely necessary, why keep it? If you end up needing it, you can always go back through the revision history. (You’re not a dilettante and do have source control, right? Right?) At worst, leave a comment and mention the source control revision in which the deleted code can be found. There, now you can get rid of the code.

Deleting code is the greatest pleasure in the life of a programmer. If you don’t understand that in your guts, well I’m sorry, but you’re not a programmer. (You may yet become one, mind; but you aren’t one now.)

Re:Ah yes:

rjbs on 2008-01-28T13:30:26

I once boasted that I had deleted more code at $JOB than I had written. I'm afraid that isn't quite true -- then or now -- but I like to think that I keep the ratio pretty close to 1.

I love the feeling of deleting awful old code. It's like, I don't know, throwing away my meds for some horrible disease I've overcome.

Man, you are tough

jonasbn on 2008-01-28T11:57:10

But I agree, deletion is a privilege we sometimes forget that we have and there is nothing like the feeling of cleaning up code.

I should schedule some regular refactoring session, just to get that special kick, I have seen several DRY violations in the code base.

But again, time is not on my side.

Re:Man, you are tough

Aristotle on 2008-01-28T14:42:25

Yeah, time pressure can make you do horrible things to a codebase. I know all too well.

As for tough, well… I can’t really put this in few words, because it’s a big issue with many sides. The best I have seen it explained is by MJD in his Program Repair Shop talk at last year’s YAPC::Asia. I really recommend that; watch it if you can. He makes a string of very good points about repetition, and more generally redundancy, in code.

Die die die

runrig on 2008-01-28T17:30:17

At $former_employer, programmers had the nasty habit of copying and commenting out entire functions, entire classes even, to change a few lines of code. This was in a $language (not perl) that made it easy to do so...by commenting out the first line of an indented block, the whole block was commented. It made it hell to search for anything in the code. I wrote a perl utility to remove all such blocks before I started working on any such file. No one ever missed the code. And it was all in revision control (albeit a crappy one) anyway.

Re:Die die die

runrig on 2008-01-28T19:15:54

...should've said "by commenting out the line before an indented block".

Re:Die die die

Aristotle on 2008-01-29T02:19:26

It’s odd. For some strange reason, people Don’t Understand Source Control. And they have this inexplicable discomfort about deleting code.

My impression is that this is a consequence of programming by coincidence, but I don’t know if that’s a sufficient (or even at all correct) explanation.