How to Write a Comment in a Computer Programming Language

Understand the purpose of commenting a computer program., Think of a short, simple way to get across your point., Write the comment using the appropriate syntax given by the programming language. , Ask yourself if the comment you've written is...

5 Steps 1 min read Medium

Step-by-Step Guide

  1. Step 1: Understand the purpose of commenting a computer program.

    Readability is the key thing here.

    When you look at a comment you should know that it is a comment and not a line of code.

    The comment should also be helpful not just to you, but to anyone else that might read the source code of your computer program.
  2. Step 2: Think of a short

    Comments don't need to be a work of art.

    They should be concise, neat, and straight to the point.

    This should not, however, discourage the use of multiple lines for a comment.

    The point is that the information needs to get across to the reader. ,, A comment should be able to tell someone looking at the source code what that part of the program actually does without having to compile it and run it.

    Does your comment accomplish this? Does it convey all the details?
  3. Step 3: simple way to get across your point.

  4. Step 4: Write the comment using the appropriate syntax given by the programming language.

  5. Step 5: Ask yourself if the comment you've written is detailed enough.

Detailed Guide

Readability is the key thing here.

When you look at a comment you should know that it is a comment and not a line of code.

The comment should also be helpful not just to you, but to anyone else that might read the source code of your computer program.

Comments don't need to be a work of art.

They should be concise, neat, and straight to the point.

This should not, however, discourage the use of multiple lines for a comment.

The point is that the information needs to get across to the reader. ,, A comment should be able to tell someone looking at the source code what that part of the program actually does without having to compile it and run it.

Does your comment accomplish this? Does it convey all the details?

About the Author

S

Sara Rivera

Specializes in breaking down complex hobbies topics into simple steps.

42 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: