views:

175

answers:

5

Is there any need for code with author's name added in every function or even the files?

Yes code will be in source control and many programmers involved

+12  A: 

If the code is under source control, no.
That kind of data should be stored in the source code repository.

If the code is meant to be widely distributed (in other environment without any kind of repository), then yes, that could be useful. (some java sources do include that kind of information, as well as the release number from which some evolution of the code are available)

Obviously that kind of information (for widely deployed code base) is at the file level only.
Consider for example the source code of java.lang.Boolean in Java:

/**
 * [...]
 * In addition, this class provides many methods for 
 * converting a {@code boolean} to a {@code String} and a 
 * {@code String} to a {@code boolean}, as well as other 
 * constants and methods useful when dealing with a 
 * {@code boolean}. 
 *
 * @author  Arthur van Hoff
 * @version 1.60, 05/05/07
 * @since   JDK1.0
 */
public final class Boolean implements  java.io.Serializable,
    Comparable<Boolean> {
[...]

You do not have all the authors from the beginning of time, only the most recent one, with the associated last major version for the most recent modification, and the version for the original introduction of the class.

That can help for API tooling for example, when you want to maintain good APIs.

But informations about the author is still limited to the file, not the functions: he represents the coordinator or aggregation manager for all the functions present in the class, even though there may have been more than one contributor over time.

As such, this is a public information, worthy of being put explicitly in the file, as opposed to a private meta-data (who writes what), stored as all other meta-data (date, version, branch, merge information, ...) in a source code repository.

VonC
… for *every single function*? How many authors does a class have? And wouldn’t it be enough to specify them once, for the whole class?
Konrad Rudolph
@Konrad: true, i was referring to the "even the files" part of the OP's question. I have not seen that information on functions.
VonC
Even in cases where it makes sense, the author and version info should be stamped in using the RCS keywords feature of the VCS being used. Relying on engineers to maintain this information manually *will* lead to inaccurate info in the comments file.
John Stauffer
@John: not sure. 1/ RCS is "evil" (see the debate on this SO answer: http://stackoverflow.com/questions/645008/what-are-the-basic-clearcase-concepts-every-developer-should-know/645424#645424 ). 2/ the case which makes sense (*public* source code) should mean: one or two "main" authors, accountable for the evolutions, and not *every* authors that ever modified the file.
VonC
+1  A: 

No. You or the company you work for implicitly has copyright. But that being said for tracking purposes it can be useful to ask that person what this code did later.

David Allan Finch
That is what SCC is for...
Mitch Wheat
I am not sure that copyright notices can be placed in metadata. But VonC's answer is more complete.
David Allan Finch
+6  A: 

According to Code Complete, comments are used to illustrate the purpose of the code. Using it for other purposes may result in 'comment decay'.

That said, keeping track of code ownership, change-log and who last modify the file, IMHO, is the job of a source control repo like SVN and such, and should not be inside the comments. Unless it is a license of some sorts. Or use an IDE's bookmark system to keep track of who authored a function, and who is the person responsible for it.

All this are just my 2 cent worth, though.

Extrakun
A: 

yes it is needed. Also if possible give the date alongwith the name. It is used for the tracking purpose as well as gives priviledge to others to know the owner of that function.

PJ
+2  A: 

Yes code will be in source control

Then no. Source control takes care of tracking this (blame).

Especially for team OpenSource projects, it might be useful or necessary to indicate the author of a particular piece of code. But commenting on every single function seems really excessive, especially since most of a class will be written by the same author (n’est-ce pas?). I like the Java library convention of specifying the author(s) for each class. Somehow, this seems to be the right trade-off.

On the flipside, if you co-authored a class, you’re to blame if someone else writes bad code in it. I actually think that this is a good thing. A class (in OOP, at least) is one entity so the quality is determined by its overall quality. If one function is bad, so is the whole class.

Konrad Rudolph