Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Code with author's name absolute necessary?

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

like image 869
yesraaj Avatar asked Sep 02 '09 08:09

yesraaj


People also ask

How do you comment out a code?

How to comment Code: Primarily, a single "block" comment should be placed at the top of the function (or file) and describe the purpose the code and any algorithms used to accomplish the goal. In-line comments should be used sparingly, only where the code is not "self-documenting".

Should you comment your code?

A good goal is to have 1 comment for every 1-4 lines of code. Be sure to not only document what your code is doing, but, as you begin writing more advanced code, you should document what was intentionally left out, optimized away, tried and discarded, etc - basically, any design decision you make.


2 Answers

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.

like image 66
Extrakun Avatar answered Oct 21 '22 08:10

Extrakun


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.

like image 39
VonC Avatar answered Oct 21 '22 06:10

VonC