    <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  :: Francis' Scribbles</title>
        <link>https://members.accu.org/index.php/articles/1158</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">Francis' Scribbles from CVu journal + CVu Journal Vol 14, #2 - Apr 2002</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/c181/">Francis' Scribbles</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/c115/">142</a>
<br />

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

                    -                        <a href="https://members.accu.org/index.php/articles/c181+115/">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;Francis' Scribbles</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 07 April 2002 13:15:50 +01:00 or Sun, 07 April 2002 13:15:50 +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="d0e18" id="d0e18"></a>Book of the
Year 2001</h2>
</div>
<p>When I wrote my last column I felt certain that the ACCU
membership would grab the opportunity to give credit to authors
that had helped them. How wrong could I be? Just three people went
to the trouble of emailing me a list of any kind. As the whole
point of the exercise was to break away from the past where I made
up my mind as to where to cast my favours I am left with a problem.
Authors value the plaudit of having their worked designated as book
of the year by organisations such as ACCU, and I am sure that many
would value even a nomination. We need to give every encouragement
to good authors. That means more than just buying their books. We
need to tell them what we like and what we do not. Reviews do part
of the job, but there is more.</p>
<p>Having thought about it, I have decided to ask those attending
the ACCU Spring Conference to make nominations on the first day.
Perhaps by way of encouragement I will persuade Blackwells Bookshop
to provide a small prize that can be drawn for from those who have
provided nominations. Unfortunately this has disenfranchised the
membership from voting, but I think you lost your vote when you
chose not to make a nomination.</p>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e25" id="d0e25"></a>Conference
Concerns</h3>
</div>
<p>I have had several emails as well as a couple of posts to
comp.lang.c++.moderated concerned with various aspects of the
conference. Let me deal with them here.</p>
<p>Several people are unhappy that it is so close to Easter. There
are very serious constraints under which we work. The timing of
academic holidays is critical for many speakers, and note that this
is not only UK academic holidays. In addition we have other events
that interact. We could have held the event at the end of April in
Curu&ccedil;ao but I think the consequential costs would have
deterred most from attending. Why there? Because that is where
about half the speakers will be at that time as that is when and
where WG14 and WG21 will be meeting. The second week is out,
because few speakers can afford to be in the UK for a week and then
transfer to Curu&ccedil;ao. Extending their Easter break with a
visit to the UK was possible. Both March and May hit problems with
academic commitments. If we were to have a Spring event it just
about had to be the first week of April. It is rather Holmsian,
when you have eliminated the impossible whatever remains, however
problematical, has to do.</p>
<p>The choice of location was not ideal but we were constrained by
late decisions. Despite rumours to the contrary, I have never
chosen the actual conference venue but I have specified that it
should be accessible to me because I did not want to be responsible
for an event a hundred miles or more away. You will see below that
we are already tackling this problem for next year and I hope you
will all support the result.</p>
<p>Now let me tackle costs. We try to keep these down and so do
most of our speakers. Indeed without the generosity of most
speakers and many employers we could not run this event as
economically as we do. I know that is no consolation to those who
find the costs have risen out of their reach but ACCU was willing
to subsidise those for whom this was the case but no one asked. In
round terms it cost &pound;1000 per speaker in travel,
accommodation and sustenance. And it costs &pound;50 per day per
delegate to hire rooms, provide refreshments etc. In addition there
are promotional and administrative costs. You should budget for at
least one person's working time for six months. In planning for
next year I will be sitting down with our organiser and looking to
see if there is any way to reduce costs in future but it will not
be by any dramatic amount. Of course if we knew twice as many
people would come we could probably shave 25% off the cost.</p>
<p>Promoting our events any way you can reduces costs by increasing
attendance. We need employers to realise that this is the event to
send their developers to. That is the message that has to be got
home. We can keep striving to do better internally but we should
make sure that those with the purse strings know that ours is
already one of the most cost effective events available. Actually,
I am quite certain that our events are the best available at any
cost.</p>
<p>Getting management support is a long-term process. When you have
been to an ACCU conference make sure management know, and continue
to remember how useful it has been. There are many opportunities to
gently push home the message, learn to spot them and exploit
them.</p>
<p>I still find members who seem to think their membership of ACCU
is something that they should not be open about with their
colleagues. I am at a loss to understand this. The benefits of
membership in general and attending our conference in particular
are substantial and you should want your colleagues to know what
they are missing. Which leads me to:</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e42" id="d0e42"></a>Telling People
About ACCU</h3>
</div>
<p>I was visiting Blackwells yesterday and noticed a lone figure
struggling to choose a book on C++. Being me, and having a few
moments to spare I started with one of my standard pick-up lines:
'Are you trying to learn C++?' That started a conversation in which
I could point him to a suitable book (as he had done some
programming before and knew the rudiments, though nothing about
C++, <i class="citetitle">Accelerated C++</i> was the obvious
choice.) In the conversation he revealed that he was working for a
local company developing educational software in collaboration with
Oxford University. Now I have a way into a company that will
certainly benefit from ACCU membership. Of course I still have to
land the fish, but the hook has been planted.</p>
<p>The programming section of your local bookshop is a rich fishing
ground for new members. It is a pity more members do not fish
there. As the Bible teaches (and there is a lot of good advice
there even if you do not believe that it is the word of God), do
not hide your light under a bushel. We provide excellent value (for
money, if you insist) but we need to tell more people.</p>
<p>Use your voice, use your email signature and use your initiative
to spread the word. There has been virtually no growth in UK
membership for five years. There has been growth but almost
entirely in the non-UK membership. I think that if even 10% of the
membership did just a little to promote membership ACCU would grow
by at least 10% in the UK and by much more elsewhere.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e54" id="d0e54"></a>Happy News</h3>
</div>
<p>Those of you who know Herb Sutter may be surprised to learn that
he has, until now, managed to avoid marriage. That is about to
change as a young lady had both the good sense and the skill to
hook him while he was in Seattle for the October WG21 meeting. I am
sure you will all join with me in congratulating Herb and Tina (the
wedding is scheduled for early May) and wishing them many happy
years of matrimonial bliss.</p>
<p>I suspect that the other news about Herb is not unrelated. He
has just started a job at Microsoft. His job title is 'C++
Community Liaison' and he will be working from Redmond.</p>
<p>I am not sure what happened but I am getting clear messages from
several sources that Microsoft has radically changed its attitude
to C++ and the C++ Standard. This change happened some time in the
last year. A couple of the more visible hints are that they
switched Stan Lippman from C# to C++ (that was quite a surprise
when it happened last October) and this appointment of Herb. It
seems that there is now a serious chance that VC++ will become a
fully compliant C++ development system. I hope that Microsoft's
senior management do not have second thoughts.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e63" id="d0e63"></a>Future Events</h3>
</div>
<p>The UK is hosting the Spring meetings of WG21 and WG14 in 2003.
Barring some form of catastrophe these will take place between
March 31st and April 11th at the Holiday Inn just outside Oxford. I
do not know what experience you may have had of Holiday Inns. Mine
has been mixed. I have only just discovered that some are
franchises (and my poor experience of the one by Victoria Station,
London is an example of such a case) most are part of a company
with hundreds of hotels world-wide. The Oxford one is excellent.
More about ACCU and Holiday Inns in another column.</p>
<p>Currently we are planning the ACCU Spring Conference 2003 to be
collocated with the WG14 meeting. This will provide us access to
speakers that would not normally be available. As WG21 will be the
following week we will be able to draw on them as well. I think
that will provide us with the basis for another outstanding event.
It will also provide a potential platform for public discussion of
issues of compatibility and co-operation between the two
languages.</p>
<p>The facilities at the Oxford Holiday Inn will make organisation
of such things as Birds of a Feather meetings as well as informal
late night sessions relatively easy.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e72" id="d0e72"></a>An Essential
Tool</h3>
</div>
<p>One of the things that continues to amaze me is the reaction
that I too often get when I ask programmers about using
<span class="application">lint</span>. Many look blank and I find
myself explaining that it was the tool that K&amp;R never mentioned
because it was so fundamental to good C programming that the
authors just assumed readers would know about it.</p>
<p>In its original manifestation <span class=
"application"><span class="application">lint</span></span> was
largely concerned with inter-file dependencies. It was the
existence of <span class="application"><span class=
"application">lint</span></span> that allowed C to be written
without visible function declarations. <span class=
"application">lint</span> was deliberately very picky, so much so
that some programmers hated it. However it was doing a valuable job
by ensuring that many potential errors never propagated into
production code. Of course more sophisticated tools have been
developed. QA C is one that springs to mind. That product is
expensive but fully justifies its cost if you are working on
mission critical code.</p>
<p>C++ has many more problems, and some of those manifest directly
in a single file. A decade ago Gimpel Software produced a product
called PC-Lint for PC based development systems. It also produced a
similar product, Flexelint, for non-PC systems. The later was (and
is) fairly expensive (about $1000) because it has to be produced as
shrouded source code so that it can be compiled for the platform of
your choice. PC-Lint is not that expensive (current list price of
$239). If you do not have a copy that you regularly use then
perhaps you could write about what you do use for correcting the
numerous coding errors that litter your code. Do not tell me there
aren't any, I will not believe you and I am sure that passing a
hundred lines of your code through PC-Lint will support my
disbelief. From my perspective PC-Lint or something that does the
same job is an essential tool for professional programming in C++
(perhaps Microsoft might license it and distribute it with VC++
7.1, that would go well with their new found dedication to good C++
programming.)</p>
<p>I will try to write about it in more detail another time,
perhaps for the Members Experiences section (well I am sure several
of you could do so and save me the trouble). However let me tell
you a little tale from my time as a teacher. When I sat down beside
a pupil to work through some word processed material I would talk
it through and make corrections as I went (or sometimes get the
pupil to do so). When I had finished I would print out a copy and
hand it to the pupil saying 'Here you are, we have corrected it.'
There was usually a glow of pleasure in their eyes because it had
been corrected rather than massacred with red ink. (These days I
would switch on 'track changes' so that the original was preserved
as well as the corrected form).</p>
<p>How does that relate to using PC-Lint? Well as you work through
its diagnostics you have a choice between making changes and
overruling the program with a correctly coded comment. In other
words when a piece of source code passes PC-Lint without
diagnostics all the causes of problems have either been corrected
or have been signed off. That is exactly the right way. If I insist
that my code is correct (and it probably is) then I can take
responsibility and PC-Lint will stop nagging me about that
item.</p>
<p>If you do not know about Gimpel Software Products surf over to
<a href="http://www.gimpel.com" target="_top">www.gimpel.com</a>
and have a look. They (as far as I know) produce only the one
product but it is one that you should not be without.</p>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e104" id="d0e104"></a>Solution to
Problem 1</h2>
</div>
<p class="c2"><span class="remark">In case you missed it here is
the problem again.</span></p>
<p>Look at the following small piece of C source code and identify
all the issues that you need to consider when you want to import it
to a C++ application and to compile it with a C++ compiler:</p>
<pre class="programlisting">
#include &lt;stdio.h&gt;
int const zero;
inline int foo(void){
 return zero;
}
main(){
  int i = zero;
  i= ++i;
  int j = foo();
  printf(&quot;%d&quot;, i+j);
  return zero;
}
</pre>
<p>Several of you thought that the code was not C. Surely you must
have suspected that when I place such apparently wrong things in my
C code as <tt class="literal">inline</tt> that I knew something you
did not. Anyway, let me take the code line by line.</p>
<pre class="programlisting">
#include &lt;stdio.h&gt;
</pre>
<p>OK, nothing needs changing but many C++ programmers would
prefer:</p>
<pre class="programlisting">
#include &lt;cstdio&gt;
int const zero;
</pre>
<p>That line works fine in C because <tt class="constant">zero</tt>
will be zero initialised. If it were not for the <tt class=
"literal">const</tt> qualifier the same would apply in C++, but in
C++ if <tt class="literal">const</tt> qualified only objects of
non-POD type with a user written default constructor can be defined
without an initialiser. So we must write:</p>
<pre class="programlisting">
int const zero(0);
</pre>
<p>By the way, I prefer function style initialisation because, in
my experience, it causes fewer surprises.</p>
<pre class="programlisting">
inline int foo(void){
</pre>
<p>Now a surprise for those who have not been tracking changes to
C, <tt class="literal">inline</tt> is now a keyword of C, though
the rules are slightly different to those of C++. There is a
problem, but it is not in the use of <tt class=
"literal">inline</tt>. The problem is that in C you must designate
a single definition that is to be used when the code is not
inlined. More about that another time.</p>
<pre class="programlisting">
 return zero;
}
</pre>
<p>That is fine but the following line is not. At first sight C
programmers will just comment about implicit <tt class=
"type">int</tt>, but that earlier use of <tt class=
"literal">inline</tt> tells us that this code is for the current
version of the C standard. One change that was made in the latest
version was to remove implicit <tt class="type">int</tt> (and yes,
that does break millions of lines of legacy code. However it is
easy to fix with a one-time program to make the <tt class=
"type">int</tt>s explicit so it is the class of changes that are
acceptable even if some maybe irritated.</p>
<pre class="programlisting">
main(){
</pre>
<p>So we should amend that even for C to:</p>
<pre class="programlisting">
int main() {
  int i = zero;
  i= ++i;
</pre>
<p>Yes that line was thrown in as the easy to spot starter for one.
It causes i to be written twice without an intervening sequence
point so in both C and C++ (though not in Java) it is undefined
behaviour. Pretty stupid as well but we need a few of those to keep
you all awake. How quickly did you amend that to:</p>
<pre class="programlisting">
  ++i;
</pre>
<p>with certainty, rather than wondering if perhaps I knew
something you did not?</p>
<pre class="programlisting">
  int j = foo();
</pre>
<p>And following that blatant error we have a blatant non-error.
Another of the changes made to C in its latest standard is to allow
late definition of variables.</p>
<pre class="programlisting">
  printf(&quot;%d&quot;, i+j);
</pre>
<p>That line is fine in C but probably needs amending in C++ to
account for <tt class="literal">namespace std</tt>. How you amend
it rather depends on what other choices you made earlier. If you
did not change the header file then you can leave it as is.</p>
<pre class="programlisting">
  return zero;
</pre>
<p>Did you think about that line? If not deduct a mark. It is
correct but only because <tt class="constant">zero</tt> has the
value 0. If it had been something else then the results would
depend on the implementation. While many of the common systems
allow you to return any integer value from <tt class=
"function">main</tt>, some do not and the Standard supports that
option.</p>
<pre class="programlisting">
}
</pre>
<p>So how did you do? Perhaps I could rephrase that and ask you how
I did? Are there any things you think I missed? Or things that I
got wrong? Do not be afraid to say because one or other of us will
learn form it. Once many years ago a fellow pupil told the Maths
teacher that the answer in the back of the book was wrong. When
asked to justify it, the pupil declared that it must be because I
had a different answer. Such confidence, and misplaced at that. He
was immediately appointed by the Maths teacher as secretary of my
fan club.</p>
<p>My guideline is to always read code on the principle that there
is one more defect still to be found.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e205" id="d0e205"></a>Problem
2</h2>
</div>
<pre class="programlisting">
#include &lt;iostream&gt;
struct ex {
public:
  int a;
  void func1(){ a = 42; }
  void func2(){ 
    int b = 27, 
    a = b + 1;
  }
};
int main(){
  ex x;
  x.func1();
  x.func2();
  std::cout &lt;&lt; &quot;a = &quot; &lt;&lt; x.a;
}
</pre>
<p>So what do you think the output will be? Now be careful and
double check. It would be nice if source code checkers spotted such
typos and at least flagged them as suspect. Actually some will
because they will issue an unused variable warning. Perhaps I have
said too much. I would be interested in two things from readers.
First how quickly did you spot the error? Second, what similar
problems do you know.</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
