Click here to monitor SSC

FatherJack

SQL Q+A forum at ask.sqlservercentral.com | Follow fatherjack on Twitter

Wasted effort

Published Sunday, September 26, 2010 3:24 PM

I have mentioned putting comments in your code previously on this blog - Encouraging Comments - but I have just happened across a blog where there is a function that does date manipulation and could be handy for a project I am working on. There isn't one piece of comment in the whole 50 lines of code. The function isn't described, or even attributed, the variables are not explained, the steps are not detailed and what could have been its saving grace, an example at the end is also missing. I am now having to work through different values for each variable just to see what it should be and how I can then use it to get predictable results.

CommentsExample

For me, if there is a decent section of code at the end of a function or procedure that gives examples then that goes a long way to mitigate the crime of no comments anywhere else. In all of my production code there is a section at the bottom that show different ways of executing the procedure with a variety of valid values.

Someone new to the work can simply highlight the whole example section and press F5 to see the different returns. This lets them rapidly get to grips with the problem they are facing and resolve it. It also justifies the effort you put into your scripts, to make sure people can use them as they are intended.

Oh, the most unbelievable bit about the code I found online? It was from an MVP!

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

What do you think?

(required) 
(optional)
(required) 

About fatherjack

DBA since 1999 working for not-for-profit company. http://twitter.com/fatherjack,
Latest articles
Checking Out SQL Backup Pro 7’s New Automatic Backup Verification
 Wouldn't it be great to offload the daily chore of checking the integrity of your production... Read more...

Chuck Lathrope: DBA of the Day
 Chuck Lathrope was a finalist for the Exceptional DBA of the Year award in 2009. We contacted him to... Read more...

Backups, What Are They Good For?
 Pixar recently confessed, in an engaging video, that Toy Story 2 was almost lost due to a bad backup,... Read more...

C# Async: What is it, and how does it work?
 The biggest new feature in C#5 is Async, and its associated Await (contextual) keyword. Anybody who is... Read more...

SQL Server 2012 AlwaysOn
 SQL Server AlwaysOn provides a high-availability and Disaster-recovery solution for SQL Server 2012. It... Read more...