    <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  :: Editorial: A Glimpse Behind the Scenes</title>
        <link>https://members.accu.org/index.php/journals/249</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">Overload Journal #64 - Dec 2004 + Journal Editorial</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/c78/">Overload</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c148/">64</a>
                    (5)
<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/c185/">Editorial</a>
                    (221)
<br />

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

                    -                        <a href="https://members.accu.org/index.php/journals/c148+185/">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;Editorial: A Glimpse Behind the Scenes</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 19 December 2004 15:57:10 +00:00 or Sun, 19 December 2004 15:57:10 +00:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<p>This summer I went walking in the Lake District with my
girlfriend, and on one of the days we found ourselves walking
through a mist that reduced visibility to around 10 metres. Unable
to use other mountains as reference points (or, indeed, much of the
mountain we were on) we were reliant on a compass and dead
reckoning. Despite our best efforts we eventually found ourselves
on a scree slope with no sign of a path. We were not exactly lost -
we had a bearing to follow and would eventually reach landmarks and
a path leading us to our destination, but the going was slow and
difficult.</p>
<p>While we were debating where we'd missed the path a voice came
from the mists hiding the top of a near vertical rock face &quot;you
shouldn't be down there - the path is up here&quot;. While that gave a
point of reference, it didn't solve the problem of how to proceed
from where we had arrived. We had gone wrong, but we had company:
another group of people arrived and by all sharing the results of
exploration we found a way forward that eventually rejoined the
path.</p>
<p>This story does have relevance to Overload but, before
explaining the connection, I'm going discuss a little of what
happens behind the scenes to produce the copies of Overload that
arrive for you to read every couple of months. You have probably
guessed a part of it, but the issue that I want to address is one
that rarely makes an explicit appearance in the journal:</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p>people write articles (volunteers to do this are always
welcome);</p>
</li>
<li>
<p>the articles are reviewed by the panel of advisors (this usually
leads the authors to revise the articles); and,</p>
</li>
<li>
<p>the editor chooses the articles to accept, pass to C Vu or which
to reject completely.</p>
</li>
</ul>
</div>
<p>Usually the review by the advisors is uncontroversial, but
occasionally an article generates real debate. When considering
Jeff Daudel's article &quot;A Unified Singleton System&quot; (Overload 56)
there was such a concern over the content of the article that the
editor (then John Merrells) was moved to include an editorial
comment. And, in the next issue, one of the advisors (Mark Radford)
wrote a balancing article &quot;Singleton - The Anti-Pattern!&quot; (Overload
56).</p>
<p>Such debate is rare, most articles present material that the
whole editorial team is happy with. However, it has happened again
(but on a lesser scale). One of the articles published in the last
issue moved one of the advisors, Phil Bass, to email me
re-iterating the concerns that he expressed about the article when
first presented. I could have relegated this to the &quot;letters&quot; page
but, by implication, it raises issues of editorial policy that I
feel should be discussed.</p>
<p>First here is what Phil Bass has to say:</p>
<div class="sidebar">
<p>When Allan Kelly's article entitled &quot;The Encapsulate Context
Pattern&quot; was circulated for review I expressed considerable
disquiet. This is what I said in an email on 23rd August:</p>
<div class="blockquote">
<blockquote class="blockquote">
<p>&quot;It actually presents an Anti-Pattern as if it were a real
Pattern giving the impression that it represents good practice
when, in fact, the opposite is true.</p>
<p>Also, I believe the mention of Kevlin Henney, Frank Buschmann
and EuroPLoP gives the article an unwarranted air of authority.</p>
<p>I would prefer this not to be published. If it is published I
think it should be accompanied by further discussion so that
dissenting views can be expressed.</p>
<p>You were not convinced by my argument, no-one else expressed any
reservations and the article was published without comment. In
spite of that I remain convinced that publication of this article
did more harm than good and I would appreciate the opportunity to
argue my case in the pages of Overload.&quot;</p>
</blockquote>
</div>
<p>I will come back to Encapsulate Context in a moment, but first I
would like to make an analogy:</p>
<p><span class="bold"><b>Pattern 24 - Swap Colours</b></span></p>
<div class="variablelist">
<dl>
<dt><span class="term">Context</span></dt>
<dd>
<p>You are playing chess.</p>
</dd>
<dt><span class="term">Problem</span></dt>
<dd>
<p>You are down to one bishop and it's on a black square.
Unfortunately, your opponent's major pieces are all on white
squares and you are struggling to create an effective attack.</p>
</dd>
<dt><span class="term">Forces</span></dt>
<dd>
<div class="orderedlist">
<ol type="1">
<li>
<p>The Bishop is a useful piece. You don't want to lose it.</p>
</li>
<li>
<p>The Bishop needs to be defended, but you would prefer to use
your pieces to attack your opponent's position.</p>
</li>
</ol>
</div>
</dd>
<dt><span class="term">Solution</span></dt>
<dd>
<p>Change the colours of the squares on the board. Black squares
become white and white squares becomes black. Now you have a bishop
on a white square.</p>
</dd>
</dl>
</div>
<p>I won't try to push the analogy any further because this
&quot;pattern&quot; is quite obviously complete nonsense. It describes a
genuine problem and presents a false solution. Ignoring, for the
moment, that changing the colours of the squares is against the
rules, it actually doesn't address the real problem.</p>
<p>I believe &quot;Encapsulate Context&quot; has all the hallmarks of &quot;Swap
Colours&quot;. In my opinion, it describes a genuine problem and
presents a false solution. I will try to explain why...</p>
<p>I think it is fair to summarise &quot;Encapsulate Context&quot; as
follows:</p>
<p><span class="bold"><b>Encapsulate Context</b></span></p>
<div class="variablelist">
<dl>
<dt><span class="term">Context</span></dt>
<dd>
<p>Many systems contain data that must be generally available to
divergent parts of the system.</p>
</dd>
<dt><span class="term">Problems</span></dt>
<dd>
<p>Using global data is poor engineering practice.</p>
<p>Using long parameter lists in order to avoid global data has an
adverse effect on maintainability and object substitutability.</p>
</dd>
<dt><span class="term">Solution</span></dt>
<dd>
<p>Long parameter lists can be avoided by collecting common data
together into a Context object and passing that in parameter
lists.</p>
</dd>
<dt><span class="term">Resulting Context</span></dt>
<dd>
<p>Using a Context object improves substitutability, encapsulation
and coupling, and reduces the need for copying data.</p>
</dd>
</dl>
</div>
<p>First of all I am not at all convinced that the pattern context
occurs in well-designed systems. Allan presents an example that
purports to illustrate how the context arises, but I don't find it
at all convincing. Personally, I would not be tempted to design a
stock exchange trading system like that example, so it looks like a
straw man to me. However, let's give Allan the benefit of the doubt
and work on the assumption that such systems do exist.</p>
<p>I agree that global data is a Bad Thing. And I agree that overly
long parameter lists are a sign of a problem. But long parameter
lists are only a symptom of a deeper problem. Coalescing several
parameters into one changes the interface in only a trivial way.
The same information is passed from the client code to the
function, so coupling and cohesion are not significantly
different.</p>
<p>Now, if we consider many different functions spread throughout
the system and a Context object that contains all the global
information that any of those functions might need, things
definitely get worse. Where a function actually needs only one item
of global data we provide it with all the global data items,
introducing unnecessary coupling. And where that function
originally had direct access to the one item of global data it
needed, now it must extract it from a Context object, increasing
the complexity of the interface.</p>
<p>The resulting context is a significantly more coupled system. As
far as I can see, the effect on maintainability is minimal, there
is no effect on substitutability, and encapsulation has suffered.
We have gone from a Bad Thing to an even Worse Thing. That is the
opposite of a design pattern; it is an Anti-Pattern.</p>
<p>I will add just one further comment. If you find yourself
designing a system with significant amounts of global data and/or
passing data between distant parts of a system, you have a problem.
It may be a deep-seated problem. Think carefully about what this
data is, where it is needed and how the system is partitioned. The
problem can only be solved by a fundamental restructuring of the
system. There probably isn't a single design pattern that will do
that. &quot;Encapsulate Context&quot; won't help you. Don't use it.</p>
</div>
<p>OK, here we can see real concerns being expressed about the
article. So why then did I choose to publish it without comment?
Well, partly because the other advisors and I don't share these
concerns.</p>
<p>While we agree with Phil that it would be better to have avoided
arriving at the problem, people do get to this point and don't
always have the opportunity for a &quot;fundamental restructuring of the
system&quot;. It is more helpful to facilitate the communication between
such people than to take the part of the anonymous voice saying
&quot;you shouldn't be down there&quot;. It may serve as a warning to avoid
retracing the steps that lead to the situation, but doesn't address
the tactical problem of dealing with it.</p>
<p>Maybe I was wrong. I can imagine that some Overload reader
somewhere is facing the problems described by Allan Kelly. They
probably know they have problems, but upon reading the article they
may get the impression that the solution presented solves the
underlying problem and not only the symptomatic one. This too is a
pattern &quot;Shifting The Burden&quot; - described by Peter Senge in &quot;The
Fifth Discipline&quot; (an excellent book on organisational problems).
&quot;Shifting The Burden&quot; is a bad practice or &quot;anti-pattern&quot; largely
because by failing to address the true causes of a problem, but
giving the appearance of fixing it, it encourages the problem to
grow to proportions that make an eventual solution problematic.</p>
<p>Maybe I was right. I've used &quot;Encapsulate Context&quot; in the past -
albeit long before reading the article. I took an application that
had, scattered throughout its code, snippets of code that went to
various sources of configuration data (the Windows registry, the
command line, several databases, configuration files) and moved all
of these snippets into a context object. This made it far simpler
to test components (we didn't need to set up copies of all the
sources of configuration data for each test). When additional
configuration data was required by some new code, it was clear how
to obtain it - from the context object. And the difference between
live and test configurations became easy to parameterise. Even the
author of the original code was impressed by the changes. That
system is still running and being developed and - as of the last
report - without suffering the high maintenance/low testability
problems that are a risk of such highly-coupled approaches.</p>
<p>There is a fine line to be drawn here and, while I think that we
got this one right, it is necessary to be vigilant. The role of the
Overload team is to help the author present tools and techniques
that may be of use to the reader and let the reader be the judge of
when they are appropriate. I expect readers to use their judgement
when considering the application of such ideas - they should know
that there are always trade-offs. Knives and forks can be
dangerous, but I don't insist my children eat with blunt sticks.
And the lesson I take from my experience in the Lake District?
While it is good to know where one should be it is also worth
listening to the people solving the same problem you have
encountered where you are.</p>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
