Comment programming, also known as comment-driven development (CDD), is a (mostly) satirical
software development
Software development is the process of designing and Implementation, implementing a software solution to Computer user satisfaction, satisfy a User (computing), user. The process is more encompassing than Computer programming, programming, wri ...
technique that is heavily based on
commenting out code.
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
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.
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
A design pattern is the re-usable form of a solution to a design problem. The idea was introduced by the architect Christopher Alexander and has been adapted for various other disciplines, particularly software engineering. The " Gang of Four" ...
. 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.
Pseudocode Example:
function onClick()
In the example, there is a structure around a click
event handler
In computing, an event is a detectable occurrence or change in the system's state, such as user input, hardware interrupts, system notifications, or changes in data or conditions, that the system is designed to monitor. Events trigger responses or ...
. 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
In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.
Since a computer, at base, only ...
.
Popular culture
MSDN Swedenproduced a video for
April Fools' Day
April Fools' Day or April Fool's Day (rarely called All Fools' Day) is an annual custom on the 1st of April consisting of practical jokes, hoaxes, and pranks. Jokesters often expose their actions by shouting "April Fool " at the recipient. ...
2010, where they satirically presented CDD as if it were a serious methodology.
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.
References
{{reflist
Software development philosophies