Tagging Source Code with UUID's

Like most developers, I make a habit of staying current with technology by reading blogs and programming news sites. While I don't always agree with the author's point of view, the process forces me to evaluate my own views. Jeff Atwood posted A Modest Proposal for the Copy and Paste School of Code Reuse in which he describes copy-paste programming. While I find the post interesting, I really like the idea of unique identifiers for locating the origin of code snippets.

Code Snippets

Jeff proposes the following notation:

// codesnippet:1c125546-b87c-49ff-8130-a24a3deda659
void foo() {
    // do stuff
}

At first, I balked at the idea. I mean, we we have the URL standard for a reason, right? What is so wrong with:

// See http://www.example.com/path/to/source
void foo() {
    // do stuff
}

Then I started thinking, why can't it be both? URL's little brother is Uniform Resource Name (URN) and together they make up the Uniform Resource Identifier family. I think a very reasonable standard is to include a URI of some kind from any code you copy/paste.

Let me give two examples:

URL Based

// See http://www.example.com/path/to/source
void foo() {
    // do stuff
}

URN Based

// See urn:uuid:ae53f03b-1588-43fe-8f15-b09aeaea3f94
void foo() {
    // do stuff
}

At first, it looks a little jarring but even if you haven't seen a URN before, it is still searchable. Inquisitive developers might even spend some time looking at the URN wikipedia page.

A Request for RFC's

The unsung heroes behind all this are the clever guys at the Internet Engineering Task Force. The IETF guys spent a good amount of time coming up with standards that they propose in Request for Comments.

As developers, we spend a lot of time thinking how the current trends will shape future technologies. I believe that successful projects have their roots in the past. Let me give some examples:

  • REST? Sounds lot like RFC 2616.
  • Writing documentation containing URLs? Check out section 3 of RFC 2606.
  • Looking for a standard way to identify code snippets? RFC 1737 should set you down the right path.

Comments

No comments.