Adding copyright information when creating new files in our repos

I notice that some of the existing files in our repos begin with Multi – line comments consisting of Copyright information about the source code just as below.

/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/

At the same time some files have author’s names something like;

/**
* Created by author’s name on 26.05.15(date).
*/

Two questions are on my mind. Though with an answer on the second one which am not certain what the community has to say about it !

  1. Should this Copyright information be included when creating new files ?

  2. Is author’s name within the code base absolute necessary?

AFAIK, 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, since the code base will be in source control and many programmers will be involved in collaboration, authors name should not be inside the file comments unless it is a license of some sorts. Alternatively we can use an IDE’s bookmark system to keep track of who authored a function, and who is the person responsible for it.

cc: @dkayiwa @ibacher @mksd @burke @grace @dev5

Including the license header is part of our coding conventions and should be followed. This license header is specifically referenced in the terms of our license (the MPL-2.0). These notifications are useful to someone obtaining a part of the OpenMRS source code so it’s clear what terms the code is distributed under, how they can redistribute the code, and what notices they must retain in the code (all of this is specified in the license).

These notices are probably just part of some IDE’s standard new file template and can be deleted without consequences.

Usually not, but sometimes yes. For instance in one of our repos, we have a couple of files with the header:

/*
Copyright (c) 2010, Chin Huang

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

In this case, this is software created by someone outside of OpenMRS and not contributed to OpenMRS (software contributed to OpenMRS must be licensed under the MPL-2.0), but one of our contributors found it useful to include this part of someone else’s code in the code base. This is permitted under the terms of the license of that code provided we “retain the above copyright notice, this list of conditions and the following disclaimer”. So, to be compliant with the terms of the license for that source code, we must retain the copyright notice.

So, in place where we have a legal obligation to do so, we must retain such notices.

(I realise that you mentioned “a license of some sorts” as a possible exception; I just want to make it clear to others what that might look like)

I would say that comments primarily exist to explain code; how to use it, how it works and why a particular implementation was chosen—anything that might help another programmer coming along work out how to use the code or how to safely modify it. License headers like this, though not technical documentation, are appropriate in the sense that they explain the terms under which the code can be re-used.

“Comment decay” usually refers to the situation where a comment becomes outdated and inaccurate in such a way that instead of being helpful, it actually makes things more confusing. A classic example would be something like this:

// set to 5 to fix TRUNK-1234
private static final Integer THREE = 21;

This comment may have at one point been an accurate and useful explanation, but since the value is changed, it no longer serves that function.

A “Created By so and so…” comment doesn’t actually doesn’t become outdated in the same way, though it’s not necessarily helpful context for anyone to try to understand the code and probably should’ve been removed before the code was committed.

1 Like