    <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  :: Professionalism in Programming Part 1</title>
        <link>https://members.accu.org/index.php/journals/983</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>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">CVu Journal Vol 12, #2 - Mar 2000 + Professionalism in Programming, from CVu journal</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/journals/">All</a>

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

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

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c127/">122</a>
                    (18)
<br />

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

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c184/">Journal Columns</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c182/">Professionalism</a>
                    (40)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c127-182/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c127+182/">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;Professionalism in Programming Part 1</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 03 March 2000 13:15:35 +00:00 or Fri, 03 March 2000 13:15:35 +00:00</p>
<p><strong>Summary:</strong>&nbsp;<p>This is the first in a series of articles that will investigate professionalism in programming. Given that the ACCU exists to promote 'professionalism at all levels', these articles are going to delve into what this apparent oxymoron means. We will be addressing what makes a 'professional' programmer.</p></p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a></h2>
</div>
<p>This is the first in a series of articles that will investigate
professionalism in programming. Given that the ACCU exists to
promote 'professionalism at all levels', these articles are going
to delve into what this apparent oxymoron means. We will be
addressing what makes a 'professional' programmer.</p>
<p>I hope that for many for you this series will be instructive.
For others the issues raised here may seem 'old hat'. Please don't
let that make you dismiss what will be discussed. A lot can be
learned from simply seeing things that you take for granted written
down.</p>
<p>These articles are aimed at both people who consider themselves
'professionals' and people who aspire to be professional.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e28" id="d0e28"></a>So what is this
'professionalism'?</h2>
</div>
<p>Although that's the question that this whole series addresses,
let's try to briefly define the term 'professionalism' at the
outset. We'll also touch upon the concept of 'software engineering'
on the way. The dictionary tells us that a professional is simply a
person who performs a given activity as a career - i.e. for money.
But that's not the spirit of what we're talking about here.</p>
<p>A professional field is one that requires training, experience
and ability. The word implies a level of responsibility for what
you do. Software engineering undoubtedly requires all of these.
Being a professional implies seeking to be the best at what you do.
Even if it's not your primary job function, or if you're not yet
employed, it is natural and useful to aspire to this
professionalism in what you do.</p>
<p>If professionalism involves seeking to be better, this means
actively seeking to learn appropriate skills. Perhaps one of the
most important qualities in a professional is to appreciate what
you don't know - and to be aware of how to learn it when you need
it. The skill most hackers[<a href="#Dictionary">Dictionary</a>]
seem most proud of is the ability to blag it - pull something
together at the last minute. These kinds of pieces of work are
usually hideous hacks. This is not professional. This is not to say
that hackers cannot be engineers.</p>
<p>We should also define here the term 'software engineer' since it
is pivotal. It implies more than just a paid programmer. Software
engineering is not just sitting at a keyboard banging out programs,
software engineering is using a defined process to develop software
predictably, reliably, on time and within budget (or at least
aiming to ;-).</p>
<p>In the same way that structural engineers should follow a
rigidly defined process to design and build a bridge (you wouldn't
drive over it if they didn't, would you?) software engineering
follows a process which leads to the development of high quality
software. We'll develop this description further in a later
article.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e44" id="d0e44"></a>The madness in
our method</h2>
</div>
<p>The articles in this series will not focus simply on the single
word 'professionalism', but will discuss topics ranging from coding
style to working practices to our attitudes. Maybe some of the
topics will not seem directly related to the banner
'professionalism' (or at least no more than any of the other C Vu
articles). However, what I am trying to pull out is the
professional perspective that we should adopt behind each
particular issue.</p>
<p>So onto our first topic...</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e51" id="d0e51"></a>Layout of
source code</h2>
</div>
<p>The topic that I'm addressing in this article is something
fundamental to the source code that we write. This could been seen
as an ill advised starting point since the software engineering
process starts a great deal earlier then where we actually sit down
and write code. We all at least apply a little thought before we
fire up our editor, don't we? However, it would be churlish to
start this series with anything less contentious. Let the bun fight
begin...</p>
<p>Coding style has been, is, and will be the subject of holy wars
amongst programmers; professional, amateur, and student. Intense
disagreements occur. This is not the only such 'hot potato', you
could extend this article to cover editors, compilers,
methodologies, the one true language , and beyond.</p>
<p>The point that I hope to bring out of this is that holy wars
over these sorts of reasons are (on the whole) pointless exercises.
As 'professionals' we should step back from such petty arguments.
You should be sure of what you prefer, but not be so arrogant as to
presume that you are correct. We rarely are.</p>
<p>So what do you think is the one true way to lay out source code?
Perhaps you favour the K&amp;R flavour:</p>
<pre class="programlisting">
int foo() {
    int a, b = 0;
    for (a = 0; a &lt; MAX_A; a++) {
        b++;
    }
    return b;
}
</pre>
<p>Or perhaps you favour this:</p>
<pre class="programlisting">
int foo()
{
    int a;
    int b = 0;
    for (a = 0; a &lt; MAX_A; a++)
    {
        b++;
    }
    return b;
}
</pre>
<p>Of course there is this middle ground (the Linux kernel coding
style):</p>
<pre class="programlisting">
int foo()
{
    int a;
    int b = 0;
    for (a = 0; a &lt; MAX_A; a++) {
        b++;
    }
    return b;
}
</pre>
<p>Or if you're really perverse:</p>
<pre class="programlisting">
  int foo()
  {
int a, b = 0;
for (a = 0;
     a &lt; MAX_A;
     a++)
b++;
return b;
  }
</pre>
<p>I've seen worse, and I'm sure you could concoct something of
nightmarish proportions if you tried (see the International
Obfuscated C Code Contest winners for even better/worse examples
[<a href="#ObfuscatedC">ObfuscatedC</a>]). Do you format code to 80
or 132 column pages, or are we able to cope with more than that
these days?</p>
<p>Layout issues are a specific part of your coding presentation
style. This covers a number of things: bracket positioning, number
of spaces, and whether or not to use tabs. The wider concepts of
presentation style (e.g. function and variable names) tie in with
other coding concerns such as program structure (don't use gotos
etc) to dictate the style in which you write a program. For the
sake of time and space we are not going to address all of these
separate issues in the one article.</p>
<p>I am going to deliberately refrain from stating my particular
preference for layout because I know that it isn't right or better
than any other. Why? There is no one true way to indent your code.
No one's going to able to claim rights to the Perfect Coding Style
(TM). Although the style we chose doesn't matter, how we write our
code according to our chosen style most certainly does.</p>
<p>It can be argued that if a C/C++ standard defined the one true
coding presentation style then the world would be a better place.
After all, all code would look the same. I would raise a counter
argument to this: competition is a Good Thing. In a free market
economy, competition will drive prices down making life better for
the consumer. Monopolies foster high prices and an inferior quality
product. If we had a single monopoly coding style who would be able
to say that it was the best possible one? By actually having more
than one existent coding style to write to, it encourages us to
think and improve the way we apply a style. It encourages the style
guidelines to improve. It makes us write better code.</p>
<p>Having stated that, I will later propose a counter argument to
this counter argument.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e89" id="d0e89"></a>Why do we need
good presentation?</h2>
</div>
<p>Let us explore what is important about a code presentation
style. The style is secondary in meaning to the code - after all
the compiler ignores all that unnecessary whitespace and gets down
to the serious business of interpreting our syntax. Our indentation
is not about indicating syntactic meaning. We use it to emphasise
the logical structure of the code to human readers. It is about
communication and the clearer the better.</p>
<p>There are, in fact, three audiences for our source code.</p>
<div class="orderedlist">
<ol type="1">
<li>
<p><span class="bold"><b>Ourselves</b></span></p>
<p>My handwriting is so bad that sometimes even I can't read it.
It's practically useless unless I concentrate on writing clearly.
It's the same with our code. We have to be able to read what we
have written, immediately after having written it, but also perhaps
years later when we come back to it. Who would have expected to
come back to archaic (relatively speaking) COBOL code to have to
fix a 'Y2K' bug?</p>
<p>The intent of our code should be clear to us. If it looks a mess
then it will be harder for us to follow, and badly formatted code
may actually hide our bugs from us. As a simple example of this,
consider the following:</p>
<pre class="programlisting">
int foo()
{
int a, b = 0;
for (a = 0; a &lt; MAX_A; a++)
b++;
bar();
return b;
}
</pre>
<p>How many times did the writer intend to call <tt class=
"function">bar()</tt>?</p>
</li>
<li>
<p><span class="bold"><b>The compiler</b></span></p>
<p>The compiler does not care what the code looks like as long as
it has no syntactic errors. The intent of the code is completely
ignored - you could have the most descriptive and well-balanced
commenting in your function bodies, but if the code does not do
what your comments say the compiler won't tell you. As long as it
compiles then your development environment will be a happy
place.</p>
</li>
<li>
<p><span class="bold"><b>Others</b></span></p>
<p>This is perhaps the most important audience and the least
thought of too.So you are working in a team, but you are the only
person who will ever see your bit of code, right? Wrong.</p>
<p>You are at home writing some code for fun, no one will ever see
it, so you do not need to take care to ensure that anyone else
could follow it? How is that benefiting you? You're not developing
skills that will make you a professional.</p>
<p>Your source code is almost a formal document describing the
machine code you are creating. It needs to read clearly to whoever
comes (or might come) back to your code. On software engineered
projects this will include those auditing (code reviewing) the work
you have done, and later maintenance workers (be kind to people who
have to look after your code - you will be glad when it is you
looking after someone else's).</p>
</li>
</ol>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e128" id="d0e128"></a>What makes
for good presentation?</h2>
</div>
<p>Undoubtedly our code needs to be clearly laid out; the structure
must be enhanced by the indentation strategy, not hidden. If a
particular flow of control is necessarily complex (note the word
necessarily) then the layout should help you to read the code. (If
you've written a flow of control that is unnecessarily complex then
change it immediately).</p>
<p>Our code layout must convey meaning rather than hide it. I
suggest that these are some good metrics of the standard of an
indentation style:</p>
<div class="orderedlist">
<ol type="1">
<li>
<p><span class="bold"><b>Consistent</b></span></p>
<p>The indentation strategy should be internally consistent. Do not
change style halfway through a source file, or even a project. It
not only does not look professional, it can confuse and give the
impression that the code is not really related.</p>
<p>The style should also be consistent in the positioning of
braces/brackets etc in different situations, and the number of
spaces indent should always be the same.</p>
<p>Kernighan and Ritchie say, after stressing the importance of
having indentation: 'The position of braces is less important,
although people hold passionate beliefs. We have chosen one of
several popular styles. Pick a style that suits you, then use it
consistently.' [<a href="#Kernighan-">Kernighan-</a>]</p>
</li>
<li>
<p><span class="bold"><b>Conventional</b></span></p>
<p>It is much more beneficial to adopt one of the styles currently
in use in the industry rather than invent your own indentation
rules. You can be sure of it being accessible to others who are
reading your code. You're less likely to make people vomit.</p>
<p>This is almost a counter argument to the 'your coding style
doesn't matter' argument. But not quite.</p>
</li>
<li>
<p><span class="bold"><b>Concise</b></span></p>
<p>Can you sum your indentation strategy up concisely? Think about
it. If you do this unless such-and-such in which case you do this
if-X-holds, otherwise you do something else which depends on...</p>
<p>If it's not easy to pick up (someone may need to extend the code
you've written, and should do so in the same style) then is it
really a useful style?</p>
</li>
</ol>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e165" id="d0e165"></a>So what is
the best style?</h2>
</div>
<p>I've spent quite a lot of effort here describing what makes a
good coding style and why we need one. But now as long as you write
in a style that is 'good' it doesn't matter what style that is. And
there's no point in arguing about it.</p>
<p>There is more than one 'good' style. The quality and
applicability of styles may depend of context and culture.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e172" id="d0e172"></a>House styles
(and where to stick them)</h2>
</div>
<p>Many software-writing companies have an internal 'house style'
that defines, amongst other things, code presentation rules. These
are important and useful for a number a reasons. If everyone sings
from the same song sheet when writing code then the company can be
assured that all it's source code is consistent.</p>
<p>What does that give it? If code is released outside the
organisation then it will appear well presented, well thought out,
and cohesive if every file is formatted in the same way. The
company will also be assured that programs are written 'up to' a
certain standard by dictating common idioms and methodologies.</p>
<p>The benefits of being able to instantly recognise the shape of
one of your peer's code and be able to make appropriate maintenance
alterations is clear.</p>
<p>So these house coding standards are a Good Thing. Even if you do
not actually agree with the rules they mandate - if your
indentation strategy is much prettier and easier to understand (in
your opinion) - it should not matter to you. The benefits of
everyone sharing the same style outweigh the burden on you to have
to conform. If you don't agree with the standard you should still
work to it.</p>
<p>You may be surprised to find how much of your coding style is
bred from familiarity and practice. If you use a house style for a
while, it soon becomes second nature and seems perfectly
correct.</p>
<p>So what if you're working on code that originated from outside
the company and doesn't conform to your house style? Well, in this
kind of situation it makes more sense to write code conforming to
the existing style of the source file. (This is why writing to a
style that is easy to pick up is important.) The only other real
alternative is to convert the file (and any others) into your own
style. For most real world projects this latter course of action is
just not remotely feasible, especially if you are continually being
fed with source code updates.</p>
<p>Conform to the style of a given file/project, conform to your
house style where this doesn't conflict, and sacrifice your own
preferences. Don't surrender your style blindly, though: understand
the benefits weighed against the costs. And what if your company
doesn't have a house style? Push for one.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e189" id="d0e189"></a>Useful
wars?</h2>
</div>
<p>So engaging in 'holy wars' over code layout is a waste of time
and unproductive. Can holy wars ever be useful or productive?</p>
<p>The answer is yes. For example, the C++ community is still not
entirely sure on how best to use exceptions. Experience of their
use is only just becoming mature enough, and this is after a
considerable amount of effort. The pioneers of work with (and
without) exceptions have been discussing their merits for years,
and it is this kind of debate that is generally useful.</p>
<p>Having stated that, some of the discussions that I have seen
have been far from useful. Expressions of pure personal opinion are
largely useless, even in this pioneering context. What is needed to
advance our understanding of new territories is experience
presented in a quantifiable way.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e198" id=
"d0e198"></a>Conclusions</h2>
</div>
<p>This article has focused quite closely on code indenting style.
Hopefully, it's been a useful journey into the topic. But it's not
just about that.</p>
<p>Avoid creating hot air. The computers in my office do that for
me. Know what you like and be prepared to defend it, to put your
view across, but don't presume that you have to 'win', that you
have to be right, and don't be so arrogant as to do it your way
anyway. I'd like to encourage you to respond to what I have
written. If you disagree then please tell me so. If you agree then
it would be nice to hear. If there are certain topics that you feel
should be covered here then tell me.</p>
<div class="bibliography">
<div class="titlepage">
<h2><a name="d0e205" id="d0e205"></a>References</h2>
</div>
<div class="bibliomixed"><a name="Dictionary" id="Dictionary"></a>
<p class="bibliomixed">[Dictionary] Free Online Dictionary of
Computing. <span class="bibliomisc"><a href=
"http://wombat.doc.ic.ac.uk/" target=
"_top">http://wombat.doc.ic.ac.uk/</a></span> See term 'hacker'</p>
</div>
<div class="bibliomixed"><a name="ObfuscatedC" id=
"ObfuscatedC"></a>
<p class="bibliomixed">[ObfuscatedC] The International Obfuscated C
Code Contest. <span class="bibliomisc"><a href=
"http://wow.ioccc.org/" target=
"_top">http://wow.ioccc.org/</a></span></p>
</div>
<div class="bibliomixed"><a name="Kernighan-" id="Kernighan-"></a>
<p class="bibliomixed">[Kernighan-] Brian Kernighan, Dennis
Ritchie. <span class="citetitle"><i class="citetitle">The C
Programming Language. Second Edition</i></span>. New Jersey:
Prentice Hall. 1988. p 10 ISBN: 0-13-110362-8</p>
</div>
</div>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
