Click here to monitor SSC

FatherJack

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

Encouraging Comments

Published Wednesday, August 18, 2010 9:43 PM

Do you hate it when you open a piece of script and there are no comments? There is something comforting about seeing some lines of green text when you are up to your neck in a problem. Knowing that someone, probably the person that wrote the script was thinking about you and your predicament, even though they are not around nor have any idea why you are looking at their code.

Several years ago I was managing a young developer who had grown up coding at home, making his own websites and generally being a bit of a whizz kid. In my role I was managing his administration and development of our customer facing website and our internal web services. The problem came when he was on holiday, I might pick up a problem and not have a clue what his code was doing; include files, javascript, vbscript, innerhtml this, marquee tag that . I was lost because there was no commenting. Anywhere.

This happened a few times, each holiday was followed by a email from me whining about how I couldn't just pick up on his techniques and patterns without some guide as to the code's intention in comments. Nothing happened.

After a particular time I added comments to the code to explain to myself what I thought was going on and had a minor rant too. My sarcastic side let rip. When he came back to work he happened across the code a few days later and started laughing. Some time later I found some of his code with comments about how he was explaining what was going on to stop me adding sarcastic comments. Then it spread, film quotes, punchlines from comedy shows were appearing all over the place, along with actual code explaining comments. It had taken hold, supporting his code became simple and fun.

Whether he was treating it like graffiti and 'tagging' his code or some other reason I dont know, the result though was code that brings back memories, is fun to support and makes our jobs more fun.

I know not all places allow for this style of coding and it carries risks if they get out of hand but in this case it worked well. What methods have you got or used to encourage commenting in your code?

by fatherjack
Filed Under:

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

 

Hugo Shebbeare said:

Too funny that there re no comments on this either yet ! :)

Yes, yes, and yes, people listen to Master Allen - leave a path for others to follow, it's part of documenting your work: if you want anyone to understand how to use it, follow this simple rule.

Thank you for bring this point up.
Hugo
http://www.simple-talk.com/author/hugo-shebbeare/
September 8, 2010 4:32 PM
 

Jonathan Allen said:

I have mentioned putting comments in your code previously on this blog - Encouraging Comments - but I...
September 26, 2010 3:24 PM

What do you think?

(required) 
(optional)
(required) 

About fatherjack

DBA since 1999 working for not-for-profit company. http://twitter.com/fatherjack,
<August 2010>
SuMoTuWeThFrSa
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234
How to Kill a Company in One Step or Save it in Three
 The majority of companies that suffer a major data loss subsequently go out of business. David Wesley... Read more...

Migrating from OCS 2007 R2 to Lync: Part 4
 Having migrated the rest of our users and legacy resources across, and start getting ready to... Read more...

Automated Script-generation with Powershell and SMO
 In the first of a series of articles on automating the process of building, modifying and copying SQL... Read more...

Seth Godin: Big in the IT Business
 Seth Godin has transformed our understanding of marketing in IT. He invented the concept of 'permission... Read more...

Using SQL Test Database Unit Testing with TeamCity Continuous Integration
 With database applications, the process of test and integration can be frustratingly slow because so... Read more...