Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.

Sponsors

News

 
 
 
DZone MVB

Links

Social

Fighting against GhostDoc abusing

GhostDoc by SubMain is great tool for documenting source code. It is able to generate documentation from methods and properties names. It analyzes names and then offers appropriate description. GhostDoc is also able to use description of interface member that current property or method implements. And it takes only one simple key press.

Well, GhostDoc is great tool and I think it makes developers life easier. But not always. Don’t blame GhostDoc – the real problem is (like always) between chair and keyboard!

How to abuse GhostDoc

GhostDoc is like every good invention – one can use it and abuse it. Like a gun – you can use it to protect yourself or your home or country and you can use it to kill someone just for fun. Here is one real-life scenario.

One of the most painful things one developer can do is documenting code using GhostDoc automatically generated code with out worrying if documentation helps other developers or not. Image the class that is full of auto-generated documentation like this.

/// <summary>

/// Sets the employee phone.

/// </summary>

/// <param name="value">The value.</param>

public void SetEmployeePhone(string value)

{

    phoneLabel.Text = value;

}

Looking at method name I get exactly the same information that documentation sais - this method sets employee phone somewhere. But what is the phone here? Is it phone number or phone model or phone type? We know only that there is phone and we know that it has value. But where this value goes? Who knows…

How bad documentation affects development?

For this short method I was able to ask three questions. Let’s suppose we have 20 methods documented like this – it makes 60 questions. This amount of questions refers to serious problem of understandability of documentation. Doesn’t matter what is written in documentation – are there notes like above or some spicy yellow news about stars – it is worthless and useless for other developers.

Developers who actively abuse GhostDoc are real pain in the ass for those developers who respect their co-workers and want to write quality software. Faulty or crappy code documentation is not only useless but also dangerous because it slows down debugging process – if developer notices that there is documentation available then he or she starts reading it. Every such crappy documentation stops the reader and asks for attention.

How to avoid bad documentation?

There is no good way unless one writes brilliant GREP or PowerShell scripts to detect weird documentation blocks by patterns. Besides automatic discovery of crappy documentation you can also use most expensive resource – man power. To fight against literal anarchy in code documentation I am considering the following process:

  1. Establish rules for code documentation.
  2. Make these rules available to all developers.
  3. Look also at code documentation during code reviews.
  4. Allow developers to remove crappy documentation as soon as they find one.
  5. Make compiler generate warnings or errors when documentation is missing.

If you have suggestions then please feel free to drop a comment here.


kick it on DotNetKicks.com pimp it Progg it 顶 Shout it

Comments

DotNetShoutout said:

Thank you for submitting this cool story - Trackback from DotNetShoutout

# July 30, 2009 8:46 AM

Fighting against GhostDoc abusing | ASP Scribe said:

Pingback from  Fighting against GhostDoc abusing | ASP Scribe

# July 30, 2009 8:48 AM

DotNetBurner - ASP.net said:

DotNetBurner - burning hot .net content

# July 30, 2009 8:49 AM

PimpThisBlog.com said:

Thank you for submitting this cool story - Trackback from PimpThisBlog.com

# July 30, 2009 8:51 AM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# July 30, 2009 8:55 AM

progg.ru said:

Thank you for submitting this cool story - Trackback from progg.ru

# July 30, 2009 8:56 AM

9eFish said:

9efish.感谢你的文章 - Trackback from 9eFish

# July 30, 2009 8:57 AM

sergeb said:

Great post, Gunner!

As we have it on the product page GhostDoc is not an ultimate documentation soultion, it only generates templates to be edited by a developer, saves keystrokes is all.

Great post, again! Thanks!

# July 30, 2009 11:58 AM

DigiMortal said:

Thanks for feedback, sergeb :)

# July 30, 2009 2:15 PM

Fighting against GhostDoc abusing - Gunnar Peipman's ASP.NET blog said:

Pingback from  Fighting against GhostDoc abusing - Gunnar Peipman&#39;s ASP.NET blog

# July 31, 2009 6:31 AM

Webmaster Crap » Blog Archive » Fighting against GhostDoc abusing - Gunnar Peipman's ASP.NET blog said:

Pingback from  Webmaster Crap  &raquo; Blog Archive   &raquo; Fighting against GhostDoc abusing - Gunnar Peipman&#39;s ASP.NET blog

# July 31, 2009 7:44 AM

Jon Arild Tørresdal said:

My vote is actually for no (or close to no) comments. I suggest people try to replace comments with code, as I recently wrote about: blog.torresdal.net/.../ReplaceCommentsWithCode.aspx

# August 4, 2009 12:48 PM

JWilliams said:

You might like to check out AtomineerUtils Pro (http://www.atomineerutils.com/). Like GhostDoc, it can only produce documentation based on what your code says, so it can be abused - but it goes much further to produce a useful starting point wherever it can, so it significantly decreases the time and effort involved in documenting. It also has a number of time-saving and quality-improving features that GhostDoc is missing (e.g. word wrapping the comment text and documenting exceptions thrown in a method - things that developers usually don't bother to do because of the effort involved). It's much more configurable and supports C#, Visual Basic, C++/CLI, C++ and C code, as well as Documentation XML, Doxygen, and JavaDoc comment formats.

# September 2, 2010 1:47 AM