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.