I know your code is copyrighted.
I'm not an expert in US Copyright law, but I do know that you don't have to register a copyright to have one. All you have to do is make some utterance on your behalf or someone else's and it's owned. Write code in a file - it's owned.
Why, then, do we have copyright notices in file headers? If you want evidence of plagiarism or illicit copying, you can diff files. Court cases have turned on that sort of evidence. No, it seems that a copyright notice in a file is a warning. And, at the very least, it does indicate an owner - it tells you whose file it is. But.. why do the notices have to be so long?
Source file headers bother me, not in principle, but because people rarely know when to stop. First you have the copyright notice, then you have the disclaimers of liability, and if you are really unfortunate, you have 50 to 1000 lines of version control comments. You know, that's what we have version control systems for - to keep all of that history. There isn't much value in keeping it in the code. It's not like a file is going to wander down to the corner on its own. Code lives in an eco-system. I dare anyone to take a random file from a "enterprise" project and attempt to use it independently. It just doesn't work like that.
For better or worse, files are seen as the smallest independently distributable units in software. I suppose that if you are a lawyer, you take notice of that fact and make the file the unit of diligence. You want the notice there so that it is plain and in the face of the the potential abuser. And, if a legal notice is small, that's fine. One line, two lines.. I can handle that. The thing that I want an alternative to is the mandatory page down on open that is part and parcel of most source code. It's a tax. It is (to draw an analogy) as if every car manufacturer put a reverse etched liability disclaimer in the windshields of cars - something that you as a driver can't avoid every time you sit down in the car.
Do we really need that? I don't think so, but I do know that in most organizations, no one wants to be the one who trimmed back the mandatory header. It's just too easy to avoid that decision.. it's too easy to not be he person who said "You know, I think we can make do with a single line copyright statement and a url to our legal notices." It's such a small inconsequential issue.. unless you're a programmer.
If you're a programmer you scroll, and scroll, and scroll.
Note: this blog was inspired by a hard-edged code review done by a few years ago at a client site by "Uncle Bob" Martin.

Comments (15)
I concur. A short copyright with a link would be much nicer. Or if not that, maybe we should put the whole thing in the footer instead.
Posted by Nathan Youngman | March 26, 2008 12:31 PM
I agree that lots of header lines full of stupid boilerplate text is annoying. GNU source code used to have the entire license at the top of every single source file, which was incredibly hateful.
Nonetheless, to address just the issue of why a copyright notice at all (somewhere):
"notice of copyright using these marks may have consequences in terms of reduced damages in an infringement lawsuit"
See http://en.wikipedia.org/wiki/Copyright#Copyright_notices_in_the_U.S.
Posted by wildeye | March 26, 2008 2:47 PM
Oh, yeah! The thing that gets me is when I am asked to update the year in the copyright text, but only in files that have been modified during that year. Sure, I can do it with queries to the version control system and some scripting, but what a waste of time! I'll bet someone a good beer that there is no legal need to do this.
Posted by Matt Doar | March 26, 2008 3:45 PM
Great post. I agree completely.
Can I hijack this just a tad though -- I once interviewed with a guy who bragged how verbose his comments were.
At times he literally had a 10-line comment above a line of code.
"That's so when I come back to this, I know what the hell it's doing!" he said with a sheepish grin. He was looking for my approval when he said that. (To put it in perspective: this is a guy who's been working as the sole engineer in a company for about 20 years.)
I wanted to tell him he's wrong on at least 2 counts.
First of all, if your design/code is so damn bad that you need 10 lines of comments to explain this one line of code, you've really got to look inward and maybe wonder if you're not the best designer (he was a humble guy & would probably acknowledge that.)
Second -- and there was a very good posting on another blog recently about this -- ultimately, the compiler compiles the *code*, not the *comments*. Sure comments are great, I comment liberally, but ultimately, if you want to understand what the code is doing, YOU HAVE TO READ THE CODE.
How many of us have pored over the comments in legacy code, only to find they are out-of-date/don't match the code.
The code always matches the code. :-)
The only thing worse than no documentation is incorrect documentation.
It's the code, dummy.
Posted by Dan | March 26, 2008 5:15 PM
I've seen the fix for this in an email sig.
#include "stddisclaimer.h"
Posted by Jared Brothers | March 26, 2008 6:09 PM
Umm...
Source code revision history is really really nice.
If you've ever worked in an enterprise you would realize how nice it is to quickly view what the last few changes to the file you are working on are without having to do say "svn log ......"
Have you heard of "code folding" or are you still using notepad?
Your problem could be solved with a simple vim script.
Honestly have you ever written code in your life?
Posted by John Quincy | March 26, 2008 8:06 PM
you rock dude! nothing screams "ugly code" more than an entire page full of header nonsense. Its just ugly. Ends up making the code ugly. Ugly code sucks.
Please stop with the copyrights in the header planet earth. k thanks.
Posted by jason duncan | March 26, 2008 8:49 PM
Very nice. Clutter is the biggest indicator, a visual smell if you like, of technical debt.
http://perlbuzz.com/mechanix/2008/03/technical-debt-in-your-file-he.html
Posted by Andy Lester | March 26, 2008 10:28 PM
Some free software licenses like the MPL and CDDL are "file-based" in that code Modifications but not new additional code must fall under the same license. A copyright/license notice in each file is then unavoidable.
Posted by Reedo | March 27, 2008 3:09 PM
"Have you heard of 'code folding' or are you still using notepad?"
Amen. Get a real IDE and you won't care how long comments are...
Posted by Tom | March 27, 2008 6:35 PM
Copyright notices used to be required, much like registration. Neither has been necessary since the 1976 act. However, the notice does some fairly magical legal things. First, it constitutes publication (largely a concern with terms, since it's protected as soon as it's "fixed in a tangible form"). Second, if a work bears a copyright notice, an infringer can not claim ignorance. Third, it allows you to file for statutory damages, which are per-work instead of (and in addition to) per-copy.
For all of that, you just need the usual "Copyright xxxx-xxxx Some Person"; I think using a scond line to say "distributed under the terms of the XXX license" is at least nice because files DO get copied willy nilly, hanging about forever, and it can be a bugger to hunt down the original just to get the COPYRIGHT file out of the tarball. This also helps people who use your code protect themselves from later claims that they obtained it under some other license (or no license at all, just clear-cut infringement).
Posted by Nikolas Coukouma | March 28, 2008 4:32 AM
You did not even think of copyright regimes outside the US that may differ from what you know?
Posted by llogiq | March 28, 2008 6:23 AM
At my workplace, keeping the revision history inside the file has been proven to be quite useful: starting from reviewing daily checkins over comparing changes across multiple files, to keeping a complete revision history even when the file is renamed and the SCM throws away the revision history. But we keep it at the bottom of the file, to keep it out of the way.
But I'd like to touch on the comments issue as well: I have seen 10 lines of comment for a single line which were justified - usually because the line of code had so obscure side effects that without the comment it could never be understood. (Redesigning the system to get rid of the obscurity is not always an option unfortunately).
Also the issue of maintaining comments cuts both ways. Like it or not, when comments are in the program, they are part of the code, and need to be updated just like debug diagnostics. At minimum a good developer will remove them to avoid confusion.
Posted by Lars | March 28, 2008 6:27 PM
Source history and other header info is nice when it's up to date, but can you really be sure that every change or notable item is noted there? I know I've edited files where I checked the header, and sure enough, the code I'm looking at doesn't have much to do with the header. I'd prefer to have good in-line comments over a seldom-updated header any day. URL to company policy works as long as someone still has access to change it, if not then may as well leave that out and just stick in a one-line copyright notice so people know where the code came from (as if that matters either).
Posted by sir_flexalot | March 30, 2008 8:17 AM
Hah! This is a *brutal* dig at Emacs, which even has extended mailing list threads about changing copyright years. If you care about your users and need to put this crap in files, at least put it at the end.
Posted by sean | March 30, 2008 11:33 AM