    <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/207</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 + Francis' Scribbles from CVu journal + CVu Journal Vol 16, #2 - Apr 2004</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/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/c103/">162</a>
<br />

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

                    -                        <a href="https://members.accu.org/index.php/articles/c65+181+103/">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> 01 April 2004 22:53:48 +01:00 or Thu, 01 April 2004 22:53:48 +01:00</p>
<p><strong>Summary:</strong>&nbsp;<p>Look at the following code and decide what is wrong with it.
When you have done so, decide what it has to do with the previous
section in particular and this section of C Vu in general - well
actually the whole of your life.</p>
</p>
<p><strong>Body:</strong>&nbsp;<h2>Repository of
Projects</h2>
<p>ACCU has over a thousand paid up members and its periodicals are
read by far more than that so I am very disappointed with the
response to my request for help in the last issue of C Vu. Almost
every reader is some kind of programmer (not quite all because I
know that C Vu is also read by quite a few hangers on who enjoy the
non-technical or at least the nonprogramming part.). Almost every
programmer has learnt his or her trade by actually writing programs
to solve problems. The lucky ones actually got to write programs
that did something they found interesting or useful.</p>
<p>It takes about ten minutes to write up a simple description of a
potential programming task. If each of you just added a single
project, preferably one you would find interesting, we would soon
have a real resource to help those aspiring to become skilled
programmers.</p>
<p>I won't bore those of you familiar with the story of 'Stone
Soup' but if you do not know it take a moment to visit <a href=
"http://spanky.triumf.ca/www/fractint/stone_soup.html" target=
"_top">http://spanky.triumf.ca/www/fractint/stone_soup.html</a>.
Some activities need a well-defined team working together but many
other things can be done piecemeal with each individual adding a
little bit. If you were bored by the assignments you were given
when learning to program see if you can offer the next generation
something better. On the other hand if you had a couple of
thrilling assignments that brought programming to life for you,
pass them on to the next generation.</p>
<p>Another way to add to the resource is to provide a link to a
publicly available source of programming projects/assignments. I
might archive a copy (with permission of the owner) in case it
eventually goes away but I would be very happy to just supply a
link from my Project Repository site. Whatever you do, don't do
'nothing'.</p>
<p>That neatly leads me to the following.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2>A Simple
Program</h2>
</div>
<p>Look at the following code and decide what is wrong with it.
When you have done so, decide what it has to do with the previous
section in particular and this section of C Vu in general - well
actually the whole of your life.</p>
<pre class="programlisting">
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
using namespace std;

int main() {
  try {
    string input;
    vector&lt;string&gt; storage;
    while(true) {
      getline(cin, input);
      storage.push_back(input);
      if(!cin) cin.clear();
    }
  }
  catch(...) { cout &lt;&lt; &quot;I died\n&quot;; }
}
</pre>
<p>It does not take very long to determine that the above program
lacks an essential ingredient that we require of a program. It has
the form of a program, it will compile and it will even execute. In
doing so it will absorb all the input until one day it is full up
and falls over dead.</p>
<p>Now this column turns up in a section of C Vu entitled
'Dialogue' which is meant to be a strong hint that there should be
output from the reader as well as input. Reader and writer are
supposed to interact.</p>
<p>If you think this is something similar to what I have written
before (Hey, that is an idea James, how about me just repeating any
section of my column which gets no response on the grounds that it
obviously never reached intelligent processing.) my question is:
'What did you do about my moaning last time?'</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2>More on
Spam</h2>
</div>
<p>Well since I last wrote on the subject my ISP started filtering
spam, or claims to do so. Now what kind of email is one you do not
ever want to receive? What kind of email would you never willingly
send? So what kind of email is often not being rejected by
ISPs?</p>
<p>Yesterday I received 270 emails. 102 of those contained one or
other of the more recent viruses. My anti-virus software detected
the problem, quarantined the offending item and then sent me a
message telling me it had done so (which message I promptly told my
mail reader to reject, but that is entirely internal to my system).
Note that anti-virus software pretty quickly starts identifying new
viruses as long as you keep it up to date.</p>
<p>113 of yesterday's emails were messages from elsewhere telling
me that some item purporting to come from me (though actually
nothing to do with me) had been rejected. Most of those rejections
were because the email in question had a virus-infected attachment.
Checking back to those 102 emails of the last paragraph revealed
that a couple of dozen of the virus laden emails were actually such
rejections (or at least purported to be).</p>
<p>Much of the rest of my email was plain ordinary spam that had
managed to avoid my ISP's filter.</p>
<p>What I want to know is why any ISP is accepting email with a
detectable virus in it for onward transmission. To my mind anyone
whose email contains a detected virus should immediately have their
account suspended. Note that an ISP has to be able to identify the
origin of email from one of their clients. They know which client
sent it. Of course address forgery happens but to send email I need
a physical connection of some sort and it is that connection that
needs to be snipped as soon as my machines start attempting to mail
out virus-laden software.</p>
<p>So do you know of an ISP that both filters out all email
containing an identifiable virus and suspends the account of any
client who sends such an email? Because if you do I would seriously
consider moving my business to them.</p>
<p>You will have noted that I continued to qualify 'virus' with
identifiable. Of course there will be new viruses that will remain
undetected for a few hours but as soon as detection is possible an
ISP should apply it and destroy (not return) all infected email as
well as suspend clients who originate such email. Note that the
suspension is also beneficial to the client because they will know
very quickly that something nasty got through their defences.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2>Personal
Data</h2>
</div>
<p>I was recently attempting to register a product that I had
bought. The registration required me to provide an email address
even though there was no valid reason for the supplier to have that
address. They had not even bothered to create some ersatz reason
such as sending me a logon code. I think it is time that we all
started digging in our heels when people ask us to supply personal
data. They need to tell us why and for what it will be used.</p>
<p>Now it is hard to argue about such things when you need an
updated driver so that your purchase can be used on something such
as Windows XP. You need the update and they will not provide it
until you hand out personal data. Isn't this demanding 'personal
data' with 'menaces'? I.e. isn't it a form of extortion? Should we
not identify this as a place where the Data Protection Act (or
whatever is the equivalent in your country) is tightened up?
Something along the lines of a substantial fine for asking for
personal data without informing the person as to how it will be
used.</p>
<p>It would probably need a revision of the 'Sale of Goods Act' (or
equivalent) to make it illegal to withhold software upgrades on the
basis that the customer does not want to provide personal data.
Yes, of course I can return the goods, but when was the last time
you did that on the basis that you could not use them unless you
gave the manufacturer your telephone number?</p>
<p>Computers greatly increase the threat to our privacy because
they allow mining of immense databases. We need to fight back by
limiting what we are 'required' to provide to those databases.
Telling someone they cannot use their newly purchased scanner till
they hand over their email address is a 'requirement' in all but
name.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2>Two Little
Tools</h2>
</div>
<p>In the days when I edited C Vu I tried to get readers to share
their software experiences. With a couple of exceptions that was a
dismal failure. Let me share my own experiences with you.</p>
<p>As a result of having to learn enough about HTML, CSS and the
like in order to provide a website to support my book I found
myself looking around for some reasonable tools both for preparing
the files and for validating them. I have no doubt that there are
many such products available but all I can tell you about is the
ones that I eventually found, tried out and then purchased.</p>
<p>The first one is a product called 'Note Tab' which is intended
to be a replacement for Windows' Notepad. I very soon realised
after getting the free version from <a href=
"http://www.notetab.com" target="_top">www.notetab.com</a> that
this was an immensely more powerful tool than the one it was
replacing. Not only did it handle multiple open files but allowed
me to select what sort of thing I was working on. I could select
HTML and get a bundle of useful extras to work on HTML source. I
could then select CSS and get another bundle of tools for working
on a cascading style sheet. And so on. I could even add my own
customised support for some other activity.</p>
<p>I was impressed enough that I skipped their 30-day free trial of
the latest version and simply signed up for the full professional
version for $19.95 + VAT (which is now levied on electronic
purchases based on the origin of your credit card). The weakness of
the dollar made that pretty painless.</p>
<p>I highly recommend this product, and if you use a MS Windows
based machine try it out. If you know of something better please
take a few minutes to tell me (and through me, the readers of C Vu)
about it.</p>
<p>The second issue with preparing web pages is having some
reasonably adequate validator. The one provided by W3C is OK but it
doesn't help very much if something simply fails to pass. What I
needed was a tool that not only validated my HTML (actually, XHTML
transitional) but would give me some guidance about errors and some
advice with regard to warnings.</p>
<p><span class="emphasis"><em>[When a page fails at the W3C
validator, the reasons for the failure are given on te results page
with quite a comprehensive set of reasons for the failure -
PFJ]</em></span></p>
<p>A search of the web came up with 'CSE HTML Validator'. Details
can be found at <a href="http://www.htmlvalidator.com" target=
"_top">www.htmlvalidator.com</a>. This is another product that has
a free version which in itself is a helpful tool, or at least I
found it so. I went on to try the full standard version. At this
point I discovered a further ability of Note Tab, it can call out
to other tools and one of those is CSE HTML Validator. I could work
on a web page and hit a single hotkey to get it validated (sort of
like compiling source code).</p>
<p>This product is rather more expensive but at $69 for the full
standard version it does not seem unreasonable.</p>
<p>Here again you may know of something better or simply an
alternative. Please share your experiences. In the meantime, if you
are maintaining a website, consider trying the lite version of this
tool and see how you like it.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2>A Big
Tool</h2>
</div>
<p>The previous two programs were useful but with limited purpose.
The next product is rather more substantial. I am preparing to
write my next book and need a reasonable IDE that will run on both
MS Windows machines and Linux ones. Everything I tried had serious
flaws, like being awkward with console style programming because
the developers assumed that everyone would want to write full GUI
programs. Or they expected a bundle of overheads such as requiring
wxWindows for graphics programs. <span class=
"emphasis"><em>[wxWindows recently changed its name to wxWidgets
due to a potential problem with the original name -
PFJ]</em></span> I really do not want my readers learning more than
one thing at a time. Learning to write good C++ is enough without
having to struggle with the eccentricities of a complex graphics
library or an all singing GUI support library.</p>
<p>I kept looking and a few days ago I came across MinGWStudio. The
MS Windows version certainly looks good and has a quality feel to
it. Of course it is early days and it will have to be stress tested
before being let near my readers. There is also the issue as to
whether the Linux version will also pan out OK. Ian Bruntlett is
preparing to test that with my library source code. If that works
OK then it looks like another product whose praises I will be
willing to sing.</p>
<p>It is free but the developer is asking for donations, which
considering the magnitude of the product seems very fair to me.</p>
<p>If you already know about this product please share your
experiences. If you do not I think it might be worth your trying
it. You can get more details at <a href="http://www.parinya.ca"
target="_top">www.parinya.ca</a>. By the way it also provides a
FreeBSD version, if anyone reading this uses that OS and would like
to try the Unix version of my library with it please drop me a
line.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e124" id=
"d0e124"></a>Australia</h2>
</div>
<p>By the time you read this I will have got back. I hope that my
absence for three weeks has not caused anyone any problems. I will
let you know what gets done out there in the next issue. However as
a result of my last column I got an email from a long-standing ACCU
member who now lives in Melbourne. I knew Alec Clews when he lived
and worked in England and I am very much looking forward to meeting
him again. I am glad I told you all where I was going otherwise I
would have missed meeting Alec. Friendships that endure over the
years and over long distances are made so much easier by modern
technology. Do not get conned by those who claim that computers
turns us into recluses; they can but they do not have to.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2>Commentary on
Problem 13</h2>
</div>
<p>Look at the following C code. Why does <tt class=
"function">qsort()</tt> fail? Please note that the <tt class=
"function">compare()</tt> function does rank any two objects of
type X.</p>
<pre class="programlisting">
struct X {
  int i;
  int j;
  int k;
};

int compare(void * p1, void * p2) {
  struct X * x = p1;
  struct X * y = p2;
  if(x.i &gt; y.i) return 1;
  if(x.j &gt; y.j) return 1;
  if(x.k &gt; y.k) return 1;
  return x.i + x.j + x.k - y.i - y.j - y.k;
}

int main() {
  struct X array[10];
  /* code initialising array */
  qsort(array, sixeof(X), 10, compare);
  /* etc. */
  return 0;
}
</pre>
<p>One of the key assumptions for sorting is that there is a
well-defined final order excluding that items that compare equal
may be re-ordered from one invocation of a sort algorithm to
another. The problem with the above <tt class=
"function">compare()</tt> is that there is no such guarantee. It is
perfectly possible to have three X items <tt class=
"literal">a</tt>, <tt class="literal">b</tt>, <tt class=
"literal">c</tt> such that <tt class="literal">a&gt;b</tt>,
<tt class="literal">b&gt;c</tt>, <tt class="literal">c&gt;a</tt>.
That breaks the fundamental requirement for sorting.</p>
<p>This reminds me of all those other cases where there is no
ordering. We assume that x is better than y, y is better than z
implies that x is better than z. That is a fundamental flaw in our
thinking. As soon as our choice is based on more than one criterion
the assumption is false. To put it another way, there is often no
best choice and we have to make value judgements as to what is more
important to us.</p>
<p>Good team captains implicitly understand that 'better' is not an
absolute when they seek to exploit their opponents' weaknesses. For
example, if your cricket opponent does not have any leg spin
bowlers you can safely select a batsman who is vulnerable to leg
spin.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3>Christmas
Competition</h3>
</div>
<p>Well there were no other entries other than those from John
Kewley and Richard Blundell. I see no reason to distinguish between
their excellent clues so they each win a copy of any book from the
C++ In Depth Series or a copy of either the C or the C++ Standard
as published by Wiley.</p>
<p>If they will email me their choices I will get copies out to
them as soon as I have recovered from my visit to Australia.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3>
</div>
<p>Another form of numerical clue is to use the time or date of
some event that is well known to the readership. Clues actually
using a time tend to be very much local to groups but dates can be
more general:</p>
<div class="blockquote">
<blockquote class="blockquote">
<p>When next Julian has one that Gregory skips. (4 digits)</p>
</blockquote>
</div>
<p>If you saw that clue without any context you might not
immediately think of Gregorian and Julian calendars. However the
clue does hint at time by use of 'When next' and so the experienced
solver of cryptic clues should stop and think about calendars. What
is the difference between the Julian and the Gregorian calendar?
The algorithm for determining leap years. And now the answer should
be clear. 2100 AD is the next time that the Julian calendar inserts
a leap day when the Gregorian one does not.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3>On
Reflection</h3>
</div>
<p>Some of the digits have reflective symmetry (0, 1, 3, 8) though
'3' only reflects vertically. Note that 0, 1, 8 also have
rotational symmetry. '6' and '9' are special because they are
rotations of each other.</p>
<p>This property of the glyphs we use to represent digits opens up
some potential for cryptic clues:</p>
<div class="blockquote">
<blockquote class="blockquote">
<p>The beast turning round causes a very British call for help.</p>
</blockquote>
</div>
<p>Gives '999' to anyone who either knows their Bible or the
English emergency phone number.</p>
<p>Now see if you can come up with a good clue for '9901'. Of
course you can use any of the ideas I have presented over the last
year as well as any of your own.</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
