    <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  :: Naming Conventions for Spoken Readability</title>
        <link>https://members.accu.org/index.php/articles/775</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, #2 - Feb 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/c133/">112</a>
<br />

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

                    -                        <a href="https://members.accu.org/index.php/articles/c65+133/">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;Naming Conventions for Spoken Readability</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 03 February 1999 13:15:29 +00:00 or Wed, 03 February 1999 13:15:29 +00: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>If you wrote a sentence in a serious document and realised that
it made a silly rhyme, would you want to change it? Of course you
would, because otherwise the rhyme would be distracting from what
you are saying. But what about the following code?</p>
<pre class="programlisting">
Colour colour = new Colour (Colour::red);
</pre>
<p>This might be read as &quot;colour colour equals new colour colour
red&quot;. Most of the information here is conveyed in the symbols and
the case, rather than the words. It uses a common naming convention
that class names should begin with a capital letter and instance
names with a lower case one, and a too common practise that an
instance can be called the same thing as its class, but for a case
difference.</p>
<p>Naming conventions are useful for avoiding confusion. For
example, two ways of avoiding confusion between parameters and
member data are:</p>
<p>Method 1: Prefix &quot;the&quot; to all member data</p>
<pre class="programlisting">
MyObject::MyObject(int someData) {
  theSomeData=someData;
}
</pre>
<p>Method 2: Prefix &quot;in_&quot; to all parameters</p>
<pre class="programlisting">
MyObject::MyObject(int in_someData) {
  someData=in_someData;
}
</pre>
<p>Of course, you can use '<tt class=
"literal">this-&gt;someData=someData</tt>', but that is more
confusing, especially if you try to use it in a constant
initialiser:</p>
<pre class="programlisting">
MyObject::MyObject(int someData) : someData(someData) {};
</pre>
<p>The point: It helps if you have a naming convention, but some
naming conventions are better than others. Hungarian notation is a
naming convention and I think I'd better not get into that debate
(if I had any bricks through my window I'd be liable &#9786;).</p>
<p>The colour example is confusing to blind people working with
speech synthesisers (which are not ideal interfaces for working
with code - Braille is much better but not so widely available),
and I'm considering writing some kind of filter to sort people's
code out for them, although I'm not sure about the feasibility of
this in the general case. You might be able to tell the difference
between Colour and colour by context (or get your synth to
tediously read out the case of every letter), but &quot;possible&quot; is not
the same as &quot;ideal&quot;.</p>
<i><span class="remark">I think you need context sensitive speech
synthesiser. Now that would be an interesting project.
Francis</span></i>
<p>If I tried to persuade everyone to adapt their naming
conventions for blind people, I'd just get accused of being
extremist. But speech synthesis is not the only time you might want
to read code. When discussing code (especially over the telephone)
you need to convey it orally, preferably in a reasonably efficient
and easy-to-understand way. Many people think verbal thoughts while
reading to themselves, and if code is easy to read verbally then
this can help. So I think that, where possible, consideration
should be given to making code verbally readable.</p>
<p>As an example of this, compare the following:</p>
<pre class="programlisting">
shape.draw(screen);
shape.drawTo(theScreen);

something.writstat(true);
something.setWritingStatusTo(true);

something.writstat();
something.getWritingStatus();

Colour colour=new Colour();
Colour drawing_col=new Colour();
</pre>
<p>I don't want to lay down any firm rules, since every piece of
code is different. If experienced code authors were vaguely trying
to make their code verbally readable then they should have little
problem in doing it (in whatever language provided that the
language itself allows readable code), and I'm convinced that it
can only be a good thing. But I tend to prefer beginning 'set' and
'get' methods with 'set' and 'get', so it's obvious that you're
talking about a method and not a field.</p>
<p>What about identifiers with many words in them? One common
convention is to begin each new word with a capital letter, and
this is the one that Java uses. Fortunately some speech synths can
be told to begin a new word at every capital, so the pronunciation
is not garbled. If you are reading the code visually though then it
can depend on the font you're using - in particular, the relative
dimensions of capital and lower case letters. If it is not obvious
where the capitals are then you have to look at the identifier for
longer to find them before you can split it into words. I can
change the font, but fully sighted people have a general tendency
to not know much about fonts. But whether it is a good thing or not
can depend on the identifier - are the words long or short? Are
there more than two or three words in the same identifier? (If so
then it can be a problem!) Is one word ending with a letter that
looks similar to the capital of the next? And so on.</p>
<p>The alternative is to use underlines (_) to separate the words.
This can make for longer identifiers and slower visual reading
(because you tend to 'notice' the underlines even if you don't say
'underline') and can also slow down your typing (touch-typing an
underline can take a significant fraction of a second), but there
should be no problem in picking out the words. Speech synths can be
told to treat underline as whitespace.</p>
<p>If you can't touch-type (and I'm surprised at the number of
programmers who can't) or you have one of those badly-designed
laptop keyboards or a Macintosh (that puts the tactile markings in
confusingly non-standard places), you may still be able to write
long identifiers quickly by using one of those editors that lets
you type in part of an identifier and completes it for you.</p>
<p>Some people find identifiers that are entirely in capital
letters hard to read, and these are sometimes used for
pre-processor macros. It can depend on their frequency of use
though - if one is only ever used about twice in a large program
then it can be more acceptable than using it every other line.</p>
<p>Of course, some programmers will find that their English is not
yet good enough to know how readable a piece of code with English
identifiers is. Some &quot;localised&quot; compilers let you write
identifiers in languages with characters other than those occurring
in the ASCII set. For example, I recently came across someone who
had learned C++ with a &quot;Chinese compiler&quot;, that let you have
Chinese identifiers. The problem with this is that it ties you to
one particular compiler and compromises on the portability of C++.
What would happen to your code if that compiler is no longer
supported in the next decade, and the machines it runs on are
ancient and no longer used by anyone? What if you want to
distribute your code in source form, or port it to some other
platform? If you must write identifiers in these languages then it
would be better to use their romanised forms (Pinyin, Romaji etc) -
tone Pinyin without the brackets will compile OK.</p>
<p>I thought of hacking out a converter for Chinese C++, that
generates ASCII identifiers to replace the Chinese characters (and
substitutes hex sequences in string literals), so that the code can
be compiled using any other compiler. However, then I found out
about one localised compiler that not only allows you to put
Chinese characters in identifiers but also re-defines the behaviour
of the string functions to cope with them. This is so horribly
non-standard it makes it almost impossible to port code between
that compiler and any other in any reasonable length of time. How
can a compiler writer know that, whenever a programmer writes
<tt class="function">strlen()</tt>, she means &quot;number of characters
in the string&quot;? I could write <tt class="function">strlen()</tt>
when I actually wanted to know the number of bytes. What these
localised compilers are effectively doing is creating another
language, superficially like C or C++ but too proprietary to
interact fully with it. It may still be possible to write a
converter from the 'localised' version to the real language, but
you would have to re-write half the standard libraries at the same
time.</p>
<p>Localised versions of languages may increase readability for
some people, but I think they defy the original point of the
languages. If you want to create a new language, go ahead, but
don't pretend it's interoperable with the existing ones when it
isn't.</p>
<i><span class="remark">I think we need to examine the tools that
we use for code preparation. We are already getting quite effective
speech to text tools but cannot capitalise on these for writing
code. Clearly colour can help with our understanding of a piece of
code. However in both cases the tools need to understand context.
We need context sensitive tools. We know what can be achieved and
we know that many could benefit so why doesn't someone get on and
do it? An IDE that allowed me to dictate my code, could read it
back to me and could use colour to highlight selected features
would, I think, have substantial sales. Start telling your tool
vendors (and in the USA remind them that they are supposed to
actively consider the needs of the disabled)</span></i></div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
