Comment programming
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.
A lot of programmers code acts as a fingerprint. Most of the time, it is sloppy and can be hard to dissect. Even experienced programmers write sloppy code. Comments guide and provide context for the user. Comments can also serve as placeholders for future work. They are useful when constructing outlines of large programs.[2]
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.
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 someoe 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.
Popular culture
MSDN Sweden produced a video for April Fools' Day 2010, where they satirically presented CDD as if it were a serious methodology.[4]
References
- ^ "Comment-Driven Development - SitePoint".
- ^ Torres, Edwin; Saba, Walid (2018-05). "Commenting on Code, Considering Data's Bottleneck". Communications of the ACM. 61 (5): 24–25. doi:10.1145/3193752. ISSN 0001-0782. Retrieved 2022-11-30.
{{cite journal}}
: Check date values in:|date=
(help) - ^ Shinyama, Yusuke; Arahori, Yoshitaka; Gondow, Katsuhiko (2018-12). "Analyzing Code Comments to Boost Program Comprehension". 2018 25th Asia-Pacific Software Engineering Conference (APSEC). pp. 325–334. doi:10.1109/APSEC.2018.00047. Retrieved 2022-11-30.
{{cite conference}}
: Check date values in:|date=
(help); Unknown parameter|booktitle=
ignored (|book-title=
suggested) (help) - ^ "Comment Driven Development - the art of removal".