When programming on a computer, sometimes it is necessary to leave notes or comments so that other developers may browse your code with ease. Whether it is an open source project or a proprietary project, comments are needed in order to coordinate with co-developers and possible future developers as well. Without comments, code would simply be unmaintainable.

Steps

  1. 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. 2
    Think of a short, simple way to get across your point. 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.
    Advertisement
  3. 3
    Write the comment using the appropriate syntax given by the programming language.
  4. 4
    Ask yourself if the comment you've written is detailed enough. 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?
    Advertisement

Community Q&A

  • Question
    How do I write programming with comments?
    Community Answer
    Community Answer
    Different languages use different comment indicators. Python, for example, uses a #, while C uses / /.
  • Question
    Which programing language is the easiest for a beginner?
    Pingu
    Pingu
    Top Answerer
    There isn't really an easiest language, as all of them have some easy and some difficult things. However, some require you to learn more advanced concepts before starting. I began to program with Python, and think that Python is quite friendly to beginners. You could also begin with something that isn't really a programming language, but shows the concepts, like Scratch, where you drag blocks around to program.

Warnings

  • Avoid over-commenting, which can make code hard to read. If extensive comments are needed, preface the code section with an explanation of how it operates. Individual steps can then be more easily described.
Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time. This article has been viewed 19,094 times.
How helpful is this?
Co-authors: 6
Updated: September 4, 2016
Views: 19,094
Categories: Programming
Advertisement