Jump to content

Comment programming

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 130.18.27.253 (talk) at 17:52, 14 September 2016 (Made article appropriately gender neutral; removed use of second person). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Comment programming, also known as comment-driven development (CDD) is a (mostly) satirical software development technique that is heavily based on commenting out code.[1]

In comment programming the comment tags are not used to describe what a certain piece of code is doing, but rather to stop some parts of the code from being executed. The aim is to have the commented code at the developer's disposal at any time it might be needed. This is especially useful when the requirements change rapidly. In this case they happen to revert to older versions of themselves, thus making the programmer either write the code again, or revert parts of the code from the versioning repository, which would be more time-consuming. With comment programming, when such a request for reverting to an old implementation arises, the developer just comments the current implementation and uncomments the previous. It is advisable to add short descriptive comments to blocks of commented code.

Practical uses

A related, but separate, more practical use of comments is for creating stubs with comments describing a feature (usually using special tags) ahead of future development of that feature. For example, this programming process can be used for prototyping a new design pattern. This is done by creating a new structure of classes or functions without any implementation, and adding the implementation at a later date.

Pseudocode Example:

function onClick()
{
   // This is where we handle mouse click.
   // The result of this function is that a button will be highlighted.
}

In the example, there is a structure around a click event handler. However, comment programming is used instead of a real implementation. The idea is that many functions can be written like this, and then the design can be reworked and revisited without having to refactor a lot of source code.

MSDN Sweden produced a video for April Fools Day 2010, where they satirically presented CDD as if it was a serious methodology.[2]

References