    <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  :: Patterns in C - Part 2: State</title>
        <link>https://members.accu.org/index.php/journals/800</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 17, #2 - Apr 2005 + Design of applications and programs</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/c97/">172</a>
                    (12)
<br />

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

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

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c67/">Design</a>
                    (236)
<br />

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

                    -                        <a href="https://members.accu.org/index.php/journals/c97+67/">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;Patterns in C - Part 2: State</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 03 April 2005 13:16:11 +01:00 or Sun, 03 April 2005 13:16:11 +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>
<p>Every non-trivial program passes through a number of different
states during its lifecycle. Describing this lifecycle as a finite
state machine is a simple and useful abstraction. In this part of
the series, we will investigate different strategies for
implementing state machines. The goal is to identify mechanisms
that let the code communicate the intent of expressing the problem
as a finite state machine.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e24" id="d0e24"></a>Traditional
Solution with Conditionals</h2>
</div>
<p>Consider a simple, digital stop-watch. In its most basic
version, it has two states: started and stopped. A traditional and
direct way to implement this behaviour in C is with conditional
logic in the shape of <tt class="literal">switch</tt>/<tt class=
"literal">case</tt> statements and/or <tt class=
"literal">if</tt>-<tt class="literal">else</tt> chains.</p>
<p>The digital stop-watch in this example is implemented as a
First-Class ADT [<a href="#Petersen">Petersen</a>].</p>
<pre class="programlisting">
typedef enum { stopped, started } State;

struct DigitalStopWatch {
  /* Let a variable hold the state of our object. */
  State state;
  TimeSource source;
  Display watchDisplay;
};

void startWatch(DigitalStopWatchPtr instance) {
  switch(instance-&gt;state) {
    case started:
      /* Already started -&gt; do nothing. */
      break;
    case stopped:
      instance-&gt;state = started;
      break;
    default: error(&quot;Illegal state&quot;); break;
  }
}
void stopWatch(DigitalStopWatchPtr instance) {
  switch(instance-&gt;state) {
    case started: 
      instance-&gt;state = stopped;
      break;
    case stopped:
      /* Already stopped -&gt; do nothing. */
      break;
    default: error(&quot;Illegal state&quot;); break;
  }
}
</pre>
<p>While this approach has the advantage of being simple and easy
to understand, it introduces several potential problems:</p>
<div class="orderedlist">
<ol type="1">
<li>
<p><span class="bold"><b>It doesn't scale.</b></span> In large
state machines the code may stretch over page after page of nested
conditional logic. Imagine the true maintenance nightmare of
changing large, monolithic segments of conditional statements.</p>
</li>
<li>
<p><span class="bold"><b>Duplication.</b></span> The conditional
logic tends to be repeated, with small variations, in all functions
that access the state variable. As always, duplication leads to
error-prone maintenance. For example, simply adding a new state
implies changing several functions.</p>
</li>
<li>
<p><span class="bold"><b>No separation of concerns.</b></span> When
using conditional logic for implementing state machines, there is
no clear separation between the code of the state machine itself
and the actions associated with the various events. This makes the
code hide the original intent (abstracting the behaviour as a
finite state machine) and thus makes the code less readable.</p>
</li>
</ol>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e66" id="d0e66"></a>A Table-based
Solution</h2>
</div>
<p>The second traditional approach to implement finite state
machines is through transition tables. Using this technique, our
original example now reads as follows.</p>
<pre class="programlisting">
typedef enum {
  stopped,
  started
} State;

typedef enum {
  stopEvent,
  startEvent
} Event;

#define NO_OF_STATES 2
#define NO_OF_EVENTS 2

static State TransitionTable[NO_OF_STATES][NO_OF_EVENTS] = {
  { stopped, started },
  { stopped, started } };

void startWatch(DigitalStopWatchPtr instance) {
  const State currentState = instance-&gt;state;
  instance-&gt;state
        = TransitionTable[currentState][startEvent];
}

void stopWatch(DigitalStopWatchPtr instance) {
  const State currentState = instance-&gt;state;
  instance-&gt;state
        = TransitionTable[currentState][stopEvent];
}
</pre>
<p>The choice of a transition table over conditional logic solved
the previous problems:</p>
<div class="orderedlist">
<ol type="1">
<li>
<p><span class="bold"><b>Scales well.</b></span> Independent of the
size of the state machine, the code for a state transition is just
one simple table-lookup.</p>
</li>
<li>
<p><span class="bold"><b>No duplication.</b></span> Without the
burden of repetitive switch/case statements, modification comes
easily. When adding a new state, the change is limited to the
transition table; all code for the state handling itself goes
unchanged.</p>
</li>
<li>
<p><span class="bold"><b>Easy to understand.</b></span> A well
structured transition table serves as a good overview of the
complete lifecycle.</p>
</li>
</ol>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e91" id="d0e91"></a>Shortcomings of
Tables</h2>
</div>
<p>As appealing as table-based state machines may seem at first,
they have a major drawback: it is very hard to add actions to the
transitions defined in the table. For example, the watch would
typically invoke a function that starts to tick milliseconds upon a
transition to state started. As the state transition isn't
explicit, conditional logic has to be added in order to ensure that
the tick-function is invoked solely as the transition succeeds. In
combination with conditional logic, the initial benefits of the
table-based solution soon decrease together with the quality of the
design.</p>
<p>Other approaches involve replacing the simple enumerations in
the table with pointers to functions specifying the entry actions.
Unfortunately, the immediate hurdle of trying to map state
transitions to actions in a table based solution is that the
functions typically need different arguments. This problem is
possible to solve, but the resulting design loses, in my opinion,
both in readability as well as in cohesion as it typically implies
either giving up on type safety or passing around unused
parameters. None of these alternatives seem attractive.</p>
<p>Transition tables definitely have their use, but when actions
have to be associated with state transitions, the State pattern
provides a better alternative.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e100" id="d0e100"></a>Enter STATE
Pattern</h2>
</div>
<p>In its description of the STATE pattern, <i class=
"citetitle">Design Patterns</i> [<a href="#GoF">GoF</a>] defines
the differences from the table-based approach as &quot;<span class=
"quote">the State pattern models state-specific behaviour, whereas
the table-driven approach focuses on defining state
transitions</span>&quot;. When applying the STATE pattern to our
example, the structure in Figure 1 emerges.</p>
<div class="figure"><a name="d0e114" id="d0e114"></a>
<div class="mediaobject c2"><img src=
"/var/uploads/journals/resources/petersen_state_pattern_structure.png" align=
"middle" alt="STATE pattern structure"></div>
<p class="title c3">Figure 1. STATE pattern structure</p>
</div>
<p>This diagram definitely looks like an object oriented solution.
But please don't worry - we will not follow the temptation of the
dark side and emulate inheritance in C. However, before developing
a concrete implementation, let's explain the involved
participants.</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p><tt class="classname">DigitalStopWatch</tt>: <i class=
"citetitle">Design Patterns</i> [<a href="#GoF">GoF</a>] defines
this as the <i class="firstterm">context</i>. The context has a
reference to one of our concrete states, without knowing exactly
which one. It is the context that specifies the interface to the
clients.</p>
</li>
<li>
<p><tt class="classname">WatchState</tt>: Defines the <i class=
"firstterm">interface</i> of the state machine, specifying all
supported events.</p>
</li>
<li>
<p><tt class="classname">StoppedState</tt> and <tt class=
"classname">StartedState</tt>: These are <i class=
"firstterm">concrete states</i> and each one of them encapsulates
the behaviour associated with the state it represents.</p>
</li>
</ul>
</div>
<p>The main idea captured in the STATE pattern is to represent each
state as an object of its own. A state transition simply means
changing the reference in the context (<tt class=
"classname">DigitalStopWatch</tt>) from one of the concrete states
to the other.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e161" id=
"d0e161"></a>Implementation Mechanism</h2>
</div>
<p>Which mechanism may be suitable for expressing this clearly
object oriented idea in C? Returning to our example, we see that we
basically have to switch functions upon each state transition.
Luckily, the C language supplies one powerful feature, pointers to
functions, that serves our needs perfectly by letting us change the
behaviour of an object at run-time. Using this mechanism, the
interface of the states would look as:</p>
<p><span class="bold"><b>Listing 1: The state interface in
<tt class="filename">WatchState.h</tt></b></span></p>
<pre class="programlisting">
/* An incomplete type for the state representation
   itself. */
typedef struct WatchState* WatchStatePtr;

/* Simplify the code by using typedefs for the
   function pointers. */
typedef void (*EventStartFunc)(WatchStatePtr);
typedef void (*EventStopFunc)(WatchStatePtr);

struct WatchState {
  EventStartFunc start;
  EventStopFunc stop;
};
</pre></div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e173" id="d0e173"></a>Breaking the
Dependency Cycle</h2>
</div>
<p>After getting used to the scary syntax of pointers to functions,
the interface above looks rather pleasant. However, with the
interface as it is, a dependency cycle will evolve.</p>
<p>Consider the pointers in the <tt class=
"classname">WatchState</tt> structure. Every concrete state has to
define the functions to be pointed at. This implies that each time
an event is added to the interface, all concrete states have to be
updated. The resulting code would be error-prone to maintain and
not particularly flexible.</p>
<p>The good news is that breaking this dependency cycle is simple
and the resulting solution has the nice advantage of providing a
potential error-handler. The trick is to provide a default
implementation, as illustrated in the listing below.</p>
<p><span class="bold"><b>Listing 2: Extend the interface in
<tt class="filename">WatchState.h</tt></b></span></p>
<pre class="programlisting">
/* ..previous code as before.. */
void defaultImplementation(WatchStatePtr state);
</pre>
<p><span class="bold"><b>Listing 3: Provide the default
implementations in <tt class=
"filename">WatchState.c</tt></b></span></p>
<pre class="programlisting">
static void defaultStop(WatchStatePtr state) {
  /* We'll get here if the stop event isn't
     supported in the concrete state. */
}

static void defaultStart(WatchStatePtr state) {
  /* We'll get here if the start event isn't
     supported in the concrete state. */
}

void defaultImplementation(WatchStatePtr state) {
   state-&gt;start = defaultStart;
   state-&gt;stop = defaultStop;
}
</pre></div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e199" id="d0e199"></a>Concrete
States</h2>
</div>
<p>The default implementation above completes the interface of the
states. The interface of each state itself is minimal; all it has
to do is to declare an entry function for the state.</p>
<p><span class="bold"><b>Listing 4: Interface of a concrete state,
<tt class="filename">StoppedState.h</tt></b></span></p>
<pre class="programlisting">
#include &quot;WatchState.h&quot;
void transitionToStopped(WatchStatePtr state);
</pre>
<p><span class="bold"><b>Listing 5: Interface of a concrete state,
<tt class="filename">StartedState.h</tt></b></span></p>
<pre class="programlisting">
#include &quot;WatchState.h&quot;
void transitionToStarted(WatchStatePtr state);
</pre>
<p>The responsibility of the entry functions is to set the pointers
in the passed <tt class="classname">WatchState</tt> structure to
point to the functions specifying the behaviour of the particular
state. As we can utilize the default implementation, the
implementation of the concrete states is straightforward; each
concrete state only specifies the events of interest in that
state.</p>
<p><span class="bold"><b>Listing 6: <tt class=
"filename">StoppedState.c</tt></b></span></p>
<pre class="programlisting">
#include &quot;StoppedState.h&quot;
/* Possible transition to the following state: */
#include &quot;StartedState.h&quot;

static void startWatch(WatchStatePtr state) {
   transitionToStarted(state);
}

void transitionToStopped(WatchStatePtr state) {
  /* Initialize with the default implementation
     before specifying the events to be handled
     in the stopped state. */
  defaultImplementation(state);
  state-&gt;start = startWatch;
}
</pre>
<p><span class="bold"><b>Listing 7: <tt class=
"filename">StartedState.c</tt></b></span></p>
<pre class="programlisting">
#include &quot;StartedState.h&quot;
/* Possible transition to the following state: */
#include &quot;StoppedState.h&quot;

static void stopWatch(WatchStatePtr state) {
  transitionToStopped(state);
}

void transitionToStarted(WatchStatePtr state) {
  /* Initialize with the default implementation
     before specifying the events to be handled
     in the started state. */
  defaultImplementation(state);
  state-&gt;stop = stopWatch;
}
</pre></div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e237" id="d0e237"></a>Client
Code</h2>
</div>
<p>The reward for the struggle so far comes when implementing the
context, i.e. the client of the state machine. All the client code
has to do, after the initial state has been set, is to delegate the
requests to the state.</p>
<pre class="programlisting">
struct DigitalStopWatch {
  struct WatchState state;
  TimeSource source;
  Display watchDisplay;
};

DigitalStopWatchPtr createWatch(void) {
  DigitalStopWatchPtr instance
          = malloc(sizeof *instance);
  if(NULL != instance) {
    /* Set the initial state. */
    transitionToStopped(&amp;instance-&gt;state);
    /* Initialize the other attributes here. */
  }
  return instance;
}

void destroyWatch(DigitalStopWatchPtr instance) {
  free(instance);
}

void startWatch(DigitalStopWatchPtr instance) {
  instance-&gt;state.start(&amp;instance-&gt;state);
}

void stopWatch(DigitalStopWatchPtr instance) {
  instance-&gt;state.stop(&amp;instance-&gt;state);
}
</pre></div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e244" id="d0e244"></a>A Debug
Aid</h2>
</div>
<p>In order to ease debugging, the state structure may be extended
with a string holding the name of the actual state. Example:</p>
<pre class="programlisting">
void transitionToStopped(WatchStatePtr state) {
  defaultImplementation(state);
  state-&gt;name = &quot;Stopped&quot;;
  state-&gt;start = startWatch;
}
</pre>
<p>Utilizing this extension, it becomes possible to provide an
exact diagnostic in the default implementation. Returning to our
implementation of <tt class="filename">WatchState.c</tt>, the code
now looks like:</p>
<pre class="programlisting">
static void defaultStop(WatchStatePtr state) {
  /* We'll get here if the stop event isn't
     supported in the concrete state. */
  logUnsupportedEvent(&quot;Stop event&quot;, state-&gt;name);
}
</pre></div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e258" id="d0e258"></a>Extending the
State Machine</h2>
</div>
<p>One of the strengths of the State pattern is that it
encapsulates all state-specific behaviour making the state machine
easy to extend.</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p><span class="bold"><b>Adding a new event.</b></span> Supporting
a new event implies extending the <tt class=
"classname">WatchState</tt> structure with a declaration of another
pointer to a function. Using the mechanism described above, a new
default implementation of the event is added to <tt class=
"filename">WatchState.c</tt>. This step protects existing code from
changes; the only impact on the concrete states is on the states
that intend to support the new event, which have to implement a
function, of the correct signature, to handle it.</p>
</li>
<li>
<p><span class="bold"><b>Adding a new state.</b></span> The new,
concrete state has to implement functions for all events supported
in that state. The only existing code that needs to be changed is
the state in which we'll have a transition to the new state. Please
note that the STATE pattern preserves one of the benefits of the
table-based solution: client code, i.e. the context, remains
unchanged.</p>
</li>
</ul>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e280" id="d0e280"></a>Stateless
States</h2>
</div>
<p>The states in the sample code are stateless, i.e. the <tt class=
"classname">WatchState</tt> structure only contains pointers to
re-entrant functions. Indeed, this is a special case of the STATE
pattern described as &quot;<span class="quote">If State objects have no
instance variables [&hellip;] then contexts can share a State
object</span>&quot; [<a href="#GoF">GoF</a>]. However, before sharing
any states, I would like to point to Joshua Kerievsky's advice that
&quot;<span class="quote">it's always best to add state-sharing code
after your users experience system delays and a profiler points you
to the state-instantiation code as a prime bottleneck</span>&quot;
[<a href="#Kerievsky">Kerievsky</a>].</p>
<p>In the C language, states may be shared by declaring a static
variable representing a certain state inside each function used as
entry point upon a state transition. As the variables now have
permanent storage, the signature of the transition functions is
changed to return a pointer to the variable representing the
particular state.</p>
<p><span class="bold"><b>Listing 8: Stateless entry function,
<tt class="filename">StartedState.c</tt></b></span></p>
<pre class="programlisting">
WatchStatePtr transitionToStarted(void) {
  static struct WatchState startedState;
  static int initialized = 0;
  if(0 == initialized) {
    defaultImplementation(&amp;startedState);
    startedState.stop = stopWatch;
    initialized = 1;
  }
  return &amp;startedState;
}
</pre>
<p>The client code has to be changed from holding a variable
representing the state to holding a pointer to the variable
representing the shared state. Further, the context has to define a
callback function to be invoked as the concrete states request a
state transition.</p>
<p><span class="bold"><b>Listing 9: Client code for changing
state</b></span></p>
<pre class="programlisting">
void changeState(DigitalStopWatchPtr instance, WatchStatePtr newState) {
  /* Provides a good place for controls and trace
     messages (all state transitions have to go
     through this function). */
  instance-&gt;state = newState;
}
</pre>
<p>The stateless state version comes closer to the STATE described
in <i class="citetitle">Design Patterns</i> [<a href=
"#GoF">GoF</a>] as a state transition, in contrast with the
previous approach, implies changing the object pointed to by the
context instead of just swapping its behaviour.</p>
<p><span class="bold"><b>Listing 10: State transition in <tt class=
"filename">StoppedState.c</tt></b></span></p>
<pre class="programlisting">
static void startWatch(DigitalStopWatchPtr context) {
  changeState(context, transitionToStarted());
}
</pre>
<p>A good quality of the stateless approach is that the point of
state transitions is now centralized in the context. One obvious
drawback is the need to pass around a reference to the context.
This reference functions as a memory allowing the new state to be
mapped to the correct context. Another drawback is the care that
has to be taken with the initialization of the static variables if
the states are going to live in a multithreaded world.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e333" id=
"d0e333"></a>Consequences</h2>
</div>
<p>The main consequences of applying the State pattern are:</p>
<div class="orderedlist">
<ol type="1">
<li>
<p><span class="bold"><b>Reduces duplication introduced by complex,
state-altering conditional logic.</b></span> As illustrated in the
example above, solutions based upon large segments of conditional
logic tend to contain duplicated code. The STATE pattern provides
an appealing alternative by removing the duplication and reducing
the complexity.</p>
</li>
<li>
<p><span class="bold"><b>A clear expression of the intent. The
context delegates all state dependent operations to the state
interface.</b></span> Similar to the table-based solution, the
STATE pattern lets the code reflect the intent of abstracting the
problem as a finite state machine. With complex, conditional logic,
that intent is typically less explicit.</p>
</li>
<li>
<p><span class="bold"><b>Encapsulates the behaviour of each
state.</b></span> Each concrete state provides a good overview of
its behaviour including all events supported in that very state.
This encapsulation makes it easy both to identify as well as
updating the relevant code when changes to a certain state are to
be done.</p>
</li>
<li>
<p><span class="bold"><b>Implicit error handling.</b></span> The
solutions based on conditional logic, as well as the table-based
one, requires explicit code to ensure that a given combination of
state and event is valid. Using the technique described above of
initializing with a default implementation, the controls are built
into the solution.</p>
</li>
<li>
<p><span class="bold"><b>Increases the number of compilation
units.</b></span> The code typically becomes less compact with the
STATE pattern. As <i class="citetitle">Design Patterns</i> says
&quot;<span class="quote">such distribution is actually good if there
are many states</span>&quot; [<a href="#GoF">GoF</a>]. However, for a
trivial state machine with few, simple states, the STATE pattern
may introduce an unnecessary complexity. In that case, if it isn't
known that more complex behaviour will be added, it is probably
better to rely on conditional logic so the logic will be easy to
follow.</p>
</li>
</ol>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e373" id="d0e373"></a>Summary</h2>
</div>
<p>The STATE pattern lets us express a finite state machine, making
the intent of the code clear. The behaviour is partitioned on a
per-state basis and all state transitions are explicit.</p>
<p>The STATE pattern may serve as a valuable tool when implementing
complex state-dependent behaviour. On the other hand, for simple
problems with few states, conditional logic is probably just
right.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e380" id="d0e380"></a>Next
Time</h2>
</div>
<p>We'll continue with <i class="citetitle">Design Patterns</i>
[<a href="#GoF">GoF</a>] and investigate the Strategy pattern,
which is closely related to STATE. The STRATEGY pattern lets us
implement different variation points of an algorithm,
interchangeable at run time.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e391" id=
"d0e391"></a>Acknowledgements</h2>
</div>
<p>Many thanks to Magnus Adamsson, Tord Andersson, and Andr&eacute;
Saitzkoff for their feedback.</p>
</div>
<div class="bibliography">
<div class="titlepage">
<h2><a name="d0e396" id="d0e396"></a>References</h2>
</div>
<div class="bibliomixed"><a name="Petersen" id="Petersen"></a>
<p class="bibliomixed">[Petersen] Adam Petersen , &quot;Patterns in C,
part 1&quot;, <span class="citetitle"><i class="citetitle">C
Vu</i></span> 17.1</p>
</div>
<div class="bibliomixed"><a name="GoF" id="GoF"></a>
<p class="bibliomixed">[GoF] Gamma, E., Helm, R., Johnson, R., and
Vlissides, J, <span class="citetitle"><i class="citetitle">Design
Patterns</i></span>, Addison-Wesley</p>
</div>
<div class="bibliomixed"><a name="Kerievsky" id="Kerievsky"></a>
<p class="bibliomixed">[Kerievsky] Joshua Kerievsky , <span class=
"citetitle"><i class="citetitle">Refactoring to
Patterns</i></span>, Addison-Wesley</p>
</div>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
