    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: COMMENTS- A Personal Perspective</title>
        <link>https://members.accu.org/index.php/articles/904</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>




<div class="xar-mod-head"><span class="xar-mod-title">Programming Topics + CVu Journal Vol 11, #5 - Aug 1999</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c65/">Programming</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c130/">115</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c65-130/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c65+130/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;COMMENTS- A Personal Perspective</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 03 August 1999 13:15:32 +01:00 or Tue, 03 August 1999 13:15:32 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="section" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a></h2>
</div>
<p>A high level computer program written by a human being in a 3GL
such as C, C++ or JAVA is changed by a process, usually a compiler
or an interpreter, from an easily understood language into object
code that is only understood by computers and geeks [no offence to
geeks]. With today's knowledge available, 3GL's are usually written
in such a way, by programmers, that they are self-commenting
through the use of identifier names and style. This I agree with
heartily, however this is the professional way of doing things i.e.
corporate code. Programs written to industry standards in the
commercial world are paid for.</p>
<p>To get to this point, one has to learn from the beginning. This
requires study and practice by example, great reams of explanation
from authors of what a certain statement or group of statements is
doing, and over the top commenting to get the point across, and so
the learning process has begun.</p>
<p>The books I have read usually make two points about comments</p>
<div class="orderedlist">
<ol type="1">
<li>
<p>there is the single line comment</p>
<pre class="programlisting">
// this is a single line comment
</pre></li>
<li>
<p>and a multi-line comment</p>
<pre class="programlisting">
/* here is an example
of a multi-line comment */
</pre></li>
</ol>
</div>
<p>With C only the multi-line comment was available, with C++ and
JAVA both are available and used. C++ and JAVA programmers usually
prefer the single line comments, as they are easier to spot in
documentation, although the multi-line comment must be used for
embedding comments into executable code. This is not recommended.
There would follow a brief discussion of where to use and not use
comments with regard to the working of a program and avoiding the
confusion of clashing comments with statements so as not to cause
syntax errors, but no real insight into how they are used
commercially. It isn't necessary.</p>
<p>Recently I was following a thread on ACCU-General 'Comments in
code' which for me was revealing in as much as there were not just
two sides to the debate i.e., good comments on the left and bad
comments on the right, but many varied and different views on
commenting and its repercussions and I now feel I have to put my
thoughts down so that they can be criticised.</p>
<p>Bad Examples;</p>
<pre class="programlisting">
  // adds old sales and new sales to get total sales
  totalSales = oldSales + newSales;

  // sends Hello World to the screen
  cout &lt;&lt; &quot;Hello World&quot; &lt;&lt; endl;

  return(true);  // return statement
</pre>
<p>and what I consider a good example,</p>
<pre class="programlisting">
  // this function is specific to DOS enviroments.
  // it generates a software interrupt
  // making calls directly to the BIOS
  c.index = int86(0x16, &amp;r, &amp;r);
</pre>
<p>I consider the first examples bad because they describe exactly
what the code is saying in repetitive verse and contribute nothing
constructive towards enlightenment, however they are useful at the
beginning of the said learning process, when everything is new and
being verbose is acceptable, which is where we all start before
reaching the intermediate levels.</p>
<p>I consider the last one good because it describes exactly what
will happen which is not obvious from the code and is therefore
useful in being able to follow on through what ever processes are
likely to occur later on in the program. It has been said that bad
commenting can be destructive and I only feel that this is the case
where the commentator has not grasped the logic of the problem
being solved, perhaps this is because there are two involved i.e.,
a programmer and a commentator, but I would expect this to be
unusual.</p>
<p>I think you can avoid errors if you comment code while working
on it, and I don't mean great reams of explanation, but small
snippets that will be useful when looking back at the code in a few
days time. There are two common mistakes that many of us make:
assuming no one else will read your code (in the case of a hobbyist
this might be true), that you will always remember what you wrote
and why in the future. Comments enhance the quality of the code
that we produce and benefit everyone who follows along the path of
programming, and I hope that it will continue to do so.</p>
<p class="c2"><span class="remark">My perspective is that comments
need to add enough value so that you do not stop reading them.
Every weak comment adds to the likelyhood that all comments will be
ignored.</span></p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
