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 out the current implementation and uncomments the previous. It is advisable to add short descriptive comments to blocks of commented code.

Practical uses

edit

When it comes to a work environment, it isn't about who knows the most terms out of a textbook. Instead, we are faced with problems that we aren't sure how to solve. When someone else reads a users' program, it is important for them to understand how the problem was gone about and not just to see the answer. Even if someone decides to go into something other than computer programming, they will be well equipped with the habit of comments and showing others how they thought and solved specific problems.[2]

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.

Studies show that there are mainly two types of comments being used across programs. Preconditional and Postconditional are the two biggest ideas that computer programmers should use when developing projects. Preconditional comes before the function or method have been written. They are used to describe what each block of code is supposed to do. This can guide users in the right direction if someone is trying to debug or dissect code. Postconditional comments are used after the function or set of statements have been written. They are generally used to explain to the reader why they chose to go about the problem in that manner.[3]

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.

edit

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

MCT is a tool made for programmers in order to help relieve some of the complexity in computer code. Instead of normal comments, this tool allows the addition of videos, animations, images, and voiceovers. Users are able to download this software online and can add these tools by using the cursor to drag over the line or lines they want to explain. Users are also able to add audio or hand gestures as comments. This can help explain the reasoning behind functions and how a program executes.[5]

References

edit
  1. ^ "Comment-Driven Development - SitePoint". 10 October 2007.
  2. ^ "Information Technology Student: Computer Programming & Support". NSDL. Retrieved 2022-12-01.
  3. ^ Shinyama, Yusuke; Arahori, Yoshitaka; Gondow, Katsuhiko (December 2018). "Analyzing Code Comments to Boost Program Comprehension". 2018 25th Asia-Pacific Software Engineering Conference (APSEC). pp. 325–334. arXiv:1905.02050. doi:10.1109/APSEC.2018.00047.
  4. ^ "Comment Driven Development - the art of removal".
  5. ^ Hao, Yiyang; Li, Ge; Mou, Lili; Zhang, Lu; Jin, Zhi (2013). "MCT: a tool for commenting programs by multimedia comments". 2013 35th International Conference on Software Engineering (ICSE). ICSE '13. IEEE Press. pp. 1339–1342. doi:10.1109/ICSE.2013.6606712. ISBN 978-1-4673-3076-3. Retrieved 2022-11-30.