Sunday, October 30, 2011

The @author Tag Policy

So heres the thing

I've been thinking recently about “ ownership ” & “ responsiblities ” of code.
I am the kind of code monkey that insists that all code I write includes all required docblocks.

Why?

Simply so that any other developer looking at my code (good or bad) knows who to point the finger at if the system is fragged becase I didn't take/have (delete as appropriate) the time or couldn't be bothered to write fully functional code. Its a mentality that I'm at ease with because I don't try to hide that fact that I do on occasion write some attrocious code.

So, on all of my code, you will find my name in the @author tag, hell, just for good measure I'll throw you a few extras in some of the method doc blocks as well.

However, I am the kind of developer that is also at ease, at best rewriting, at worst totally deleting code. Code isnt' precious - believe me - it's not!

I will happily do this to my own code and guess what - I will do it to yours to!

Hell, the code could be the most beautiful fully functioning code in the world - but if it's not right for the domain at hand - its a problem and I will delete it.

Which brings me to a policy that I've had subconciously but not really thought about in any depth until recently - who's code is it?
 
When ever I rewrite code, even when that means totally trashing the file and starting a fresh, I leave the original @author tags in place and add my own to the list (after the original @author(s) I might add).

Even if the original code - line for line, method for method is garbage - the original author still had to start that feature of the code base, they still had the initial understanding that that particular feature was required - even if my three year old daughter could have produced better code.

Authorship is not just about who wrote each line, its bigger and more abstract - authorship is also about who had the original idea and did something enough to make that idea something real - even if poorly written.

If you are not using docblocks in your code - stop hiding in the shadows - be proud to put your name to it - who knows maybe I'll come along, rewrite the whole thing making it better, but I swear I'll leave your name on it - that way you can still claim that at least the idea was yours!

MonkeyPHP

No comments:

Post a Comment