Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Often in C code (and some other languages as well) I have seen a section in the top-level comments for mod lines. These include the date a modification to the file was made, the user who made the modification, and a brief description of what was changed.

I have not yet seen an equivalent of this in Java. I think this information is useful, especially when trying to track down bugs in code I did not write. Is this because Java code is often under version control, or are there other reasons? Are there any suggestions as to how to include the information in the code file?

share|improve this question
add comment

3 Answers

up vote 10 down vote accepted

I see no reason to have those useless comments in any source file. Its just reinventing version control extremely poorly.

share|improve this answer
    
What if, for whatever reason, the code cannot be placed under version control? –  Michael K Nov 1 '10 at 15:11
13  
@Michael: There is no such reason. You can always use version control, period. And if you aren't, and are using those mod lines, you're still using version control. You're just using crappy version control. –  Mark Peters Nov 1 '10 at 15:14
add comment

I've often seen Java files with a header including the original date created and the author, but not "mod lines". Version control would make that rather superfluous, as it tracks changes on a per-line basis by user.

As for why they're used in C, perhaps it's an old custom from before the days of VC.

share|improve this answer
add comment

Often in Java I see these types of lines, but it's not entered manually. Most VCSs can tag any text file with that data, as long as a template is left in the file to insert that information into.

For instance, in the VCS I use, if I include $Id: ... $ anywhere in the file, the ... will be replaced with the file name, version number, last editor, edit date, etc.

Some people think they're useless in light of VCSs (which store all of that information), but I don't. It's quick access to that information which you would have to mine for (or at least leave your file editor) by going through the VCS.

Edit: By the way, nobody's highlighted my main reason for disliking them (remember, I said they're not useless, not that I like them). I hate that they add textual changes to the file at each checkin. You either need a highly configurable diff client to ignore those changes, or you're faced with boilerplate changes at each revision which make it more cumbersome to see what actually changed.

share|improve this answer
3  
Any IDE worth using makes this information and much more accessible without significant effort. Having it in the source code is pointless noise. –  Peter Boughton Nov 1 '10 at 15:21
1  
@Peter as does any VCS itself :) –  alternative Nov 1 '10 at 15:24
1  
@mathepic: The point is, going to the VCS is usually more work than it's worth. –  Mark Peters Nov 1 '10 at 15:26
3  
@Mark Peters Typing git blame <file> is no work at all and gives a lot more information. Similarly with git log <file>. –  alternative Nov 1 '10 at 15:35
2  
@Mark Peters and if you can touch type decently the difference is virtually indistinguishable. If you can't type git blame <file>, something is wrong... And thats without considering putting a macro into your text editor. –  alternative Nov 1 '10 at 15:53
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.