Documentation: Software's Exposition

This code is written in C++; in both of these examples, comments are set off by // and in a faded grey color.

Screen Shot 2023-03-21 at 8.22.27 PM.JPEG

A snippet of an assignment for one of FSU's core programming courses.

In this code snippet, the submitter is writing a function that draws the shape of a diamond in the console using text characters, with the size and "fill character" selected by the user.

As part of this assignment, students are required to document their code, which means explaining what each major chunk or algorithm does. This makes it easier to troubleshoot if something doesn't work properly (both for the student and the grader).

The first comment, "Top Half," serves as a section header. It helps anyone scanning through the document understand where the first half of the diamond is drawn. Then, step by step, comments further describe what the algorithm does to draw the first half of the diamond.

IMG_6073.JPG

Another code snippet for an FSU project.

The comments on this piece of code are similar to the ones above, but they also serve a second purpose. "Commenting out" is the practice of quickly turning a line into a comment with the special character sequence (in this case, "//") to test whether the program works without that code.

Sometimes, programmers do the opposite: a piece of code is left "commented out" for a long time, occasionally reintroduced for testing purposes. Near the middle of this piece, the print message "in da loopdyloop..." doesn't do anything required by the assignment—instead, during a test run, it lets the programmer know that the code has gotten to that point. Essentially, the code can't have broken before here. By progressively moving these "checkpoint" messages further forward, the programmer can identify the exact point where the code stops working.

Most of the time, these checkpoints are commented out and left for when they're needed. But although they are usually ignored, they are an important indicator of how the programmer was feeling at the time of creation: in the case of "in da loopdyloop..." it seems the submitter was having a good time and goofing around.

Documentation