    <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  :: You Write - The Editor Replies</title>
        <link>https://members.accu.org/index.php/articles/743</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">Letters to the Editor + CVu Journal Vol 10, #6 - Sep 1998</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/c184/">Journal Columns</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c186/">LettersEditor</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/c135/">106</a>
<br />

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

                    -                        <a href="https://members.accu.org/index.php/articles/c186+135/">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;You Write - The Editor Replies</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 07 September 1998 13:15:28 +01:00 or Mon, 07 September 1998 13:15:28 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a></h2>
</div>
<div class="sidebar">
<p>Before I start with the main correspondence I find it necessary
to detail a couple of ground rules.</p>
<p>Normally you should send letters, comments etc. in
machine-readable form. You do not need to worry about formatting
though it would greatly help if you avoided sending material
encoded for some specialist word-processor using bizarre fonts (no
one has).</p>
<p>What you cannot do if you expect any response is to send light
grey on white hard copy (probably printed with a dot-matrix
printer) anonymously. I will scan good quality hardcopy (though it
does consume more time than I would like) but if the best scan
handed to an up-to-date OCR program cannot recognise 50% of the
text then I am not going to type it in by hand. If it is anonymous
I cannot reply asking for better copy.</p>
<p>If you are worried that your name might accidentally get
published against your wishes, provide the material for publication
in machine-readable form and provide your name in hardcopy
only.</p>
<p>I am writing this because someone actually did send me an
anonymous request for help in hardcopy of such poor quality that my
scanner/OCR gave up. For the benefit of the writer, I am not
offended just frustrated. I think you were unreasonable. I hope you
do not present job applications that way.</p>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e33" id="d0e33"></a>From Tony
Houghton</h2>
</div>
<p>Dear Francis After reading the Harpist's article on names I once
again felt moved to make a few comments.</p>
<p>The first point is scope of some types of name. The Harpist
considered <tt class="literal">enum</tt>s and <tt class=
"literal">typedef</tt>s to have global scope, with <tt class=
"literal">enum</tt>s possibly having file scope. In my opinion they
both have file scope because there's nothing but common sense to
prevent you from using the same name for two different types or
values in two different files.</p>
<p>As for <tt class="literal">struct</tt> etc tags, you can't quite
avoid using them altogether; they're needed for self-referencing
structures such as linked lists. You never need to use any tag more
than once (to give it a <tt class="literal">typedef</tt>), but
wherever there's self reference you will have to use it that
once.</p>
<p>He also said that</p>
<pre class="programlisting">
struct B {
  int data;
};
struct C {
  int data;
};
</pre>
<p>are both considered to be the same type in C. Not according to
my compiler, it wouldn't allow one to be assigned to the other or
one's address to be assigned to a pointer to the other type. I used
Acorn/ARM Norcroft C, one of the strictest ANSI compilers around.
If it were merely dubious, but legal C, I think the compiler would
be required to produce only a warning, not the error that it does.
I don't think his advice to avoid macros altogether is sound
either.</p>
<p>Constants can be better served by using <tt class=
"literal">enum</tt>s and small functions should arguably be kept as
small functions, not macros, but there are some very cunning tricks
that just aren't possible without macros. They're just about
essential to avoiding problems caused by multiple inclusion:</p>
<pre class="programlisting">
#ifndef THIS_HEADER_H
#define THIS_HEADER_H
/* Body of header */
#endif /* !defined THIS_HEADER_H */
</pre>
<p>I usually make multiple builds from one source tree of my
projects now with different levels of debugging, and being able to
pass macros into the compiler from the makefile is a much more
convenient way of controlling which type of debugging to use. I
also use a macro called <tt class="literal">E</tt> (it's used a
great deal so the less I have to type each usage the better, and I
know I'm not using '<tt class="literal">E</tt>' for anything else)
around all my OS calls to check for a returned error condition with
various levels of debugging. One of those levels of debugging
incorporates <tt class="literal">__LINE__</tt> and <tt class=
"literal">__FILE__</tt> into the error message, impossible if
<tt class="literal">E</tt> were a function.</p>
<p>I'll let him off the &quot;DON'T even think about <tt class=
"literal">goto</tt>&quot;, but I've found that they can actually improve
readability if used very carefully in certain <tt class=
"literal">switch</tt> statements where many cases share a few
common instructions. I wouldn't ever think about jumping backwards
though.</p>
<p>PS I decided to cheat with me tagline. I usually have one chosen
at random from a small selection, but now seemed like a good time
to force one of my favourites.</p>
<p>Tony Houghton <tt class="email">&lt;<a href=
"mailto:tonyh@tcp.co.uk">tonyh@tcp.co.uk</a>&gt;</tt></p>
<p class="c2"><span class="remark">There's nothing like C for doing
exactly what you didn't program</span></p>
<p><span class="bold"><b>The Harpist's respons:</b></span></p>
<p><span class="emphasis"><em>Unless there are very good reasons
otherwise, I always try to give advice on programming style that
will work equally well for C and C++.</em></span></p>
<p><span class="emphasis"><em>In C++ there is no doubt that an
<tt class="literal">enum</tt> is global unless it has been
explicitly placed in some inner scope. Until the advent of
<tt class="literal">namespace</tt> there was no way that you could
provide a non-local <tt class="literal">enum</tt> that was not
global. As far as I know, no one has ever proposed that <tt class=
"literal">enum</tt> should have internal linkage by <tt class=
"literal">static</tt> qualification of its
declaration.</em></span></p>
<p><span class="emphasis"><em>Now I grant you that a <tt class=
"literal">typedef</tt> has filescope visibility but Microsoft, in
its wisdom, provide a mechanism that turns <tt class=
"literal">typedef</tt>s identifiers into true type names. Type
names are used in name mangling in C++ and so become visible to the
linker, in other words they have extern linkage. I know that this
is not part of pure C or C++ but so many people use Microsoft
development tools that you would be unwise to ignore this
extension.</em></span></p>
<p><span class="emphasis"><em>For compatibility I would always
<tt class="literal">typedef</tt> any the tag with the same
spelling. So If I was going to use tags (and actually, for C++
portability I should) then I should write:</em></span></p>
<pre class="programlisting">
struct myType {
/* declarations */
} myType ;
</pre>
<p><span class="emphasis"><em>Though I wish that the rules of C and
C++ did not leave me writing such things for portability. To
<tt class="literal">typedef</tt> your <tt class=
"literal">struct</tt>s to anything other than the tag seems silly
to me.</em></span></p>
<p><span class="emphasis"><em>On the subject of different tags for
identical tags, I am guilty of eliding two thoughts. In C, you can
use different tags in different files yet the layout rules
guarantee that confusing them will not cause problems. This is
another way of saying that tags do not have external linkage in C.
You are of course right that the compiler can distinguish them.
Thanks for correcting me.</em></span></p>
<p><span class="emphasis"><em>Did I ever say that you should never
use macros? If so I apologise. However I have a set of very strict
requirements. Use them for header guards, nothing else works. But
always end them with _H and never ever end any other identifier
that way. If you must provide conditional compilation, then use a
sensible all upper case preprocessor identifier. Use the built-in
macros (they are there for use, so it would seem silly to remove
them, anyway they are outside the users namespace as they start
with a double underscore)</em></span></p>
<p><span class="emphasis"><em>I suppose that if you do not have any
form of configuration management that using macros the way you
suggest to control levels of debug are acceptable. However the idea
of using a single letter macro seems very suspect to me. You may
never use them for anything else but modern code is written by
extended teams.</em></span></p>
<p><span class="emphasis"><em>You may use <tt class=
"literal">goto</tt> sensibly, and I know Francis is fond of
pointing out that the Pascal goto is used by Donald Knuth in both
TEX and METAFONT. Unfortunately it is too easy to abuse and most
times what appears to be sensible use is just a symptom of a poor
code style. I frequently see it recommended as being a good way of
getting out of nested loops. However nested loops are often a
symptom of flawed programming.</em></span></p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e170" id="d0e170"></a>From Klitos
Kyriacou</h2>
</div>
<p>Hello Francis,</p>
<p>I am writing to ask about the ACCU's policies on advertising a
job through C-Vu and/or the mailing list.</p>
<p>The team I'm working in has a vacancy at the moment for a
technical consultant with good skills in (at least several of) C,
C++, Java, Corba, COM, Object-Oriented Design (including things
like OM/T, UML, Design Patterns), as well as having the right
character (business-minded, assertive, etc.)</p>
<p>Recruitment agencies have sent us people who claimed to know C++
etc. As you can imagine, we have come across too many people who
marketed themselves as C++ experts after reading bad books, like
those by Schildt and Oualline. Sometimes, it was not entirely the
candidate's fault, they mistakenly thought they knew C++ well.</p>
<p>I am more impressed by the obviously high average level of
skills shown by ACCU members. However, asking on the mailing list
would possibly be seen as commercial abuse of ACCU's facilities,
even though I am a member. Could you tell me your policy on
this.</p>
<p>Klitos Kyriacou</p>
<p class="c2"><span class="remark">I am publishing this letter for
two reasons. First one or two of you might be interested in the job
possibility. If you are, email me and I will pass it on to Klitos
who will be able to provide further information. I have not
published Klitos' email address here because this letter was an
informal one and should not involve his employer.</span></p>
<p class="c2"><span class="remark">The second reason is to respond
to his questions publicly for the benefit of all. ACCU does not
allow invitations for employment to go out other than as an advert
or letter in one of its publications. The contact details for many
members are their employers. Quite understandably employers get
very upset by having their employees canvassed for employment
elsewhere. Of course direct adverts and published letters have to
be acceptable (that is one way we raise money). Normally we charge
for advertising jobs - not much by commercial standards but a
charge none-the-less.</span></p>
<p class="c2"><span class="remark">That candidates thought they had
adequate skills but did not is the fault of the employment agency
whose service to employers should include weeding out the
under-qualified.</span></p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e194" id="d0e194"></a>From Suradet
Jitprapaikulsarn</h2>
</div>
<p>Dear Francis Glassborow,</p>
<p>First of all, I have to apologise for contacting you in this
manner. Your book reviews on ACCU has been a major sources of my
reference. Apparently, I have to teach C++ to a group of high
school students. Even though all of them have been exposed to
computer in some certain degrees, some have no programming
experiences. Could you recommend me a book that help me teach
object-oriented concept from the beginning? I believe that
object-oriented programming concept need to be incorporated from
the beginning of learning C++.</p>
<p>Looking forward for you help.</p>
<p>Suradet Jitprapaikulsarn. <tt class="email">&lt;<a href=
"mailto:suradet@gilmour.org">suradet@gilmour.org</a>&gt;</tt></p>
<p>PS: Please forgive me for my poor English.</p>
<p class="c2"><span class="remark">I have replied but I thought you
might be interested and that some of you might like to offer
advice.</span></p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e212" id="d0e212"></a>From Chris
Southern</h2>
</div>
<p>Dear Francis</p>
<p>How very dispiriting for our editor. Every issue must be a
struggle to get contributions, even letters. Yet the topic of money
brings in a torrent.</p>
<p>Well I don't want to be left out! I just need to interrupt the
paean in favour of agencies with a brief anecdote. I do not dispute
the need for them nor that the cash flow service they provide is
not essential.</p>
<p>I expected to be taken advantage of in my first contract.
But&hellip; A few months after I started it was the beginning of a
new calendar year, and one of the three agencies providing staff at
the site told its people that the employer had upped the rate in
its normal annual review. The contractors should therefore charge
at a new rate from their next invoice. The telephone lines to the
other two agencies were very busy in the hours following this
revelation. One agency said that of course the rate would go up
they just had not got round to it yet. The third said 'We pay our
contractors what we believe they are worth, and review that after
each year elapsed on a contract'. The employer was paying a flat
rate to all agencies for all contractors. In my view that would
entitle them to expect some minimum standard of contractor to be
provided, not ones that the agency felt were not worth the
money.</p>
<p>C Vu occasionally carries reviews of the SIGS Journals, e.g. C++
Report, JOOP, and I felt that a general observation might be
appropriate. I believe that articles appearing have not been
subjected to peer review in general. Some articles seem barely
disguised advertising, although it is a fine distinction to draw
between telling people how to get the best from your product and
promotion of that product to non-users.</p>
<p>The last couple of issues of Java Report have been instructive.
Obviously not all the Java developers are previous C++ developers.
Issues are being raised which the C++ community is entitled to
greet with 'been there, been bitten by that'. I was particularly
taken with the sentence describing Java's habit of passing objects
as non-const references: 'This gives the actual argument a
bewildering mixture of value semantics and reference
semantics.'.</p>
<p>Apparently not spotted as an issue was public derivation for
implementation. The thread pool class seems a good concept,
simultaneously speeding up launching a handler and preventing the
massive drain on system resources that could result from
indiscriminate spawning. But its type was '<tt class=
"classname">ThreadPool</tt> <tt class="literal">extends</tt>
<tt class="classname">java.util.Stack</tt>', and it overrode the
pop method to start a handler, and the push method to wake any
tasks that were waiting for a handler. The author even knew deep
down that something was wrong, as the push method contained the
comment '<span class="emphasis"><em>Would like to assert <tt class=
"varname">theObject</tt> is a kind-of thread</em></span>'.</p>
<p>Another article in the same issue was suggesting 'generic'
interfaces, which turn out to be run-time lookup of field and
method names in a class which would otherwise be a mostly
'getter/setter' one. This author believes that the type system is
something to be evaded, rather than a 'hard but fair' guard against
accidental misuse. I think I have been told that a class full of
fields and get/set methods with one or two methods which calculate
derived attributes is probably the wrong design. It probably comes
under the category of random cohesion, to adapt a description from
structured programming discipline.</p>
<p>Perhaps we can start a letter thread about technical issues.</p>
<p>Chris Southern <tt class="email">&lt;<a href=
"mailto:csouthern@brasspaw.cix.co.uk">csouthern@brasspaw.cix.co.uk</a>&gt;</tt></p>
<p class="c2"><span class="remark">Now I am all in favour of that
last paragraph.</span></p>
<p class="c2"><span class="remark">I have not seen copies of Java
Report so I cannot express a specific opinion but I certainly have
the impression that those writing about Java frequently lack the
kind of expertise and insights that exemplifies a good
practitioner. I wonder if we can persuade Chris to contribute a
regular report on one or two publications (particularly those aimed
at the Java community.)</span></p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e258" id="d0e258"></a>From Richard
Blundell</h2>
</div>
<p>Hi Francis,</p>
<p>I was just reading C-Vu 10-5, and thought I would send a few
comments and/or ideas. A few articles referred to previous ones
that rang no bells, and checking my shelf I couldn't find the last
issue. It is possible that I have mislaid it, but now I come to
think about it I am not sure I got one since March so I may have
missed 10-4. I'll check my desk and let (you?) know if I am out of
luck.</p>
<p>First, you mentioned the office assistant and removing it. I
have installed Rocky the dog, and personally I quite like him.
However, if you right click him, pick options, and reset all the
check boxes such as &quot;Show Tips...&quot; and &quot;Respond to F1 Help&quot;, you
should find that, once hidden, he doesn't appear much more. You can
also customise the toolbar and remove the assistant button.
Finally, if all this fails, you could delete the .act files in the
office/actors directory (in fact, to install a new assistant, all
you need to do is copy the new .act file into this directory), and
I think this should stop them appearing.</p>
<p>Rounding errors. The reason many calculators (and possibly VC,
but I'm not certain about that one) get calculations such as 1.0 /
3.0 * 3.0 correct, plus many other floating point calculations, and
give the impression that they are giving the infinite precision
results, is that they effectively store an extra digit which is
never displayed but is used solely to round answers. Thus if 1.0 /
3.0 gives 0.333(3) (let's pretend it only shows 3 d.p.) when
multiplied by 3.0 again it gives something like 0.999(9), and the
calculator uses the extra digit (shown in parentheses here) to
round the result to display 1.000. It could be that VC++ uses a
similar technique (or maybe uses a few extra bits rather than a
whole base-10 digit). Alternatively it could be using 80-bit
arithmetic in your PCs math coprocessor/FPU, and then rounding for
your double result to 64-bits, using the excess 16-bits (or at
least the excess that is part of the mantissa) for rounding.</p>
<p>Of course the more operations that are involved in a
calculation, the larger and larger any total accumulated rounding
error is likely to become, and at some point, the calculator's
trick of using an extra digit will not be enough and the error will
show up on the display. Perform even more calculations, and the
error can become sizeable. In general, therefore, when comparing
floating point numbers, I would always use a sig. figs. approach
rather than a decimal places comparison, since you have no idea how
big the numbers being compared are. If you want to compare two
numbers up to, say, 5 decimal places, then that might be fine for
numbers like your 1.414, but for numbers around a hundred you would
be stretching the precision of a <tt class="type">float</tt>. For
much larger numbers you would have the same problem with <tt class=
"type">double</tt>s. Knowing the precision at which <tt class=
"type">double</tt>s are stored on a particular machine, however,
allows you to find the number of significant digits that they will
hold. Comparing numbers to a few fewer significant digits will then
allow you test numbers of any magnitude for equality with much more
safety.</p>
<p>Thus, if you wanted to compare two numbers to 10 sig figs
(assuming your <tt class="type">double</tt>s held more than this)
you could compute something as follows (note that I have just
jotted this down, so there may be more elegant ways of doing it,
and this might not actually give you the number of significant
figures because of the way it calculates - it might be a fraction
off in general. Disclaimer, disclaimer, disclaimer 8-):</p>
<pre class="programlisting">
bool compare_sig_figs(double lhs, 
                      double rhs, int sigfigs){
    // Calculate the required maximum difference
    double epsilon = pow(10, -sigfigs);
    // Find the absolute difference between them
    double diff = fabs(rhs - lhs);
    /* Compare the fractional difference to the
       required difference.(Should really check 
       we're not going to divide by zero here!) */
    return diff / ((fabs(rhs) + fabs(lhs)) / 2) 
                                          &lt;= epsilon;
}
</pre>
<p>The reason I average the left and right hand sides is in case
they are quite different and cross zero (e.g. comparing -0.00001 to
0.1 - the result would vary widely if only one or the other were
used. You could alternatively use just the larger of the two
numbers (ignoring sign)). Note that the above will produce
undefined results when <tt class="literal">lhs == rhs == 0</tt>,
and this case needs to be checked for.</p>
<p>Here are some results from the above:</p>
<p>100.2, 100.1 at 2sf gives true 100.2, 100.1 at 3sf gives true
100.2, 100.1 at 4sf gives false 123456789.123, 123456789.122 at 8sf
gives true 123456789.123, 123456789.122 at 11sf gives true
123456789.123, 123456789.122 at 12sf gives false</p>
<p>My doubles hold 16 or 17 significant digits. As shown above, the
function distinguishes between numbers of varying magnitudes as
expected, and so using something like:</p>
<pre class="programlisting">
compare_sig_figs(a, b, 15)
</pre>
<p>would be a good way to test doubles for near-equality regardless
of their magnitude.</p>
<p>Richard Blundell <tt class="email">&lt;<a href=
"mailto:rpb@metapraxis.com">rpb@metapraxis.com</a>&gt;</tt></p>
<p><span class="bold"><b>Missing or Damaged
Magazines</b></span></p>
<p><span class="emphasis"><em>Any time you think that you have
missed a copy of C Vu just call me or even better send me an email.
I will then get you a replacement. Reasonable 'complaints' are
always dealt with promptly and with, I hope, courtesy. I would
always prefer that problems that require resupply were brought
straight to me.</em></span></p>
<p><span class="emphasis"><em>One member rang me at 9.30 one
evening, lacked the consideration to check that I was not being
inconvenienced (I do not mind calls in the evening but I should be
given the opportunity to set another time.) and started complaining
about materials damaged in the post. The main burden of his
complaint was that, while the supply officer had replaced the first
set of damaged periodicals he had declined to replace some more
that had been damaged. If he addressed another volunteer in ACCU
the same way he did me then I am not surprised that he did not
receive the treatment he thought he was entitled
to.</em></span></p>
<p><span class="emphasis"><em>By the way, if materials are damaged
in the post you should do two things: notify the sender and notify
your local post office. If materials are regularly damaged you the
problem is between you and your local postal service. For the
record I receive numerous publications through an ordinary domestic
letterbox and they are never damaged.</em></span></p>
<p><span class="bold"><b>Microsoft Office Assistant</b></span></p>
<p><span class="emphasis"><em>I remain convinced that the easiest
way to suppress Office Assistant is to uninstall it (or never
install it in the first place). The only time this is a problem is
if you are using Microsoft Office on a shared
machine.</em></span></p>
<p><span class="bold"><b>Rounding Errors</b></span></p>
<p><span class="emphasis"><em>I am familiar with guard digits but
that cannot work in C or C++ because all the bits available are
used (that is not true on all systems but it is certainly true on
MSDOS and Windows based ones. The problem is not with what is being
displayed but how the internal representation is being used. One
reason that I tested the code all the way to declaring variables as
volatile was to ensure that it could not be playing tricks with
registers. The other point was that the question was raised in a
specific set of circumstances relating to poorly designed legacy
code. There were very few options available (apart from rewrite the
entire system)</em></span></p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
