    <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  :: My Pet Project - Monopoly</title>
        <link>https://members.accu.org/index.php/articles/514</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">Design of applications and programs + Overload Journal #34 - Oct 1999</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/c67/">Design</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/c78/">Overload</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c170/">34</a>
<br />

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

                    -                        <a href="https://members.accu.org/index.php/articles/c67+170/">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;My Pet Project - Monopoly</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 26 October 1999 17:50:55 +01:00 or Tue, 26 October 1999 17:50:55 +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="d0e16" id="d0e16"></a></h2>
</div>
<p>This is the first, of a series of three articles. This first
covers an historic, non-technical look at my own learning
experiences with C, C++ and OO design and discusses the development
stages of a 'pet project' of mine. The second article looks at the
first OO attempt at this pet project and the final article looks at
using UML and Patterns.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a>A Learning
Experience</h2>
</div>
<p>How people learn is in itself a fascinating topic but in
software engineering one thing is for sure - whatever theories are
out there - it's the 'doing' that reinforces what is taught in
schools and universities or read in books.</p>
<p>I've been working in the computing industry now for nearly
twenty years and, despite it being full-time employment, I still
dabble at home on various 'pet projects'. Since early pre 'A'-level
days there has been one project in particular that has been used to
help me understand many aspects of design and implementation.</p>
<p>That project is 'to write a Monopoly&reg; program'. It's a
small, or at least well-contained, project with a clear goal, but
nevertheless presents enough problems that continually manifest
themselves in 'real-world' projects. Tackling the problems on this
'pet project' has helped me understand design issues and decisions
that have been made on projects throughout my working life. More
importantly perhaps, it helps to understand what the consequences
of those decisions will be.</p>
<p>Following is a description of each of the stages that project
has been through together with my successes and failures. It is
assumed that the reader knows the basis of the game. If not you'll
find them document on the web.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e31" id="d0e31"></a>The Stages of
this Development</h2>
</div>
<p>The Monopoly program has gone through a number of different
stages, for different reasons and different motivations. To date
these are: Assembler; C; &quot;Windowed&quot; C; Microsoft Windows;
Object-Oriented; C++; Visual C++; and finally Now!</p>
<p>Each stage is described briefly giving a little of the
background and environment, finally stating if that stage was 'a
success', 'a failure' or both.</p>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e38" id="d0e38"></a>Stage 1:
Assembler</h3>
</div>
<p>Wet behind the ears, and still at school. Thanks to the
DECSystem-10 at Hatfield Polytechnic. We were being taught
Dartmouth BASIC, but MACRO-10 (the assembler language) looked much
more exciting. It allowed access to the nuts-and-bolts of the
system (and controlled the lights on the front-panel of the CPU -
wow!). I just had to learn MACRO-10. Together with a school chum we
decided to tackle a program to play Monopoly and since then, as you
can see, the theme has stuck.</p>
<p>Success 1) The program was finished and it worked (sort of). It
controlled the game, allowed sites, houses, etc to be bought, sold,
and exchanged.</p>
<p>Success 2) Although we hadn't been taught formal structured
design and programming techniques, we ended up with a number of
small routines performing well-defined tasks. We couldn't have
known it at the time but since then I've seen many worse structured
programs written by professionals whose experience should have
taught them better.</p>
<p>Failure 1) One known unfixed bug - a flag was used for the &quot;Get
out of Jail free&quot; card, indicating if the card had already been
picked and kept by a player. The card (not being an &quot;object&quot;)
physically remained in the array of chance / community chest cards
to which it belonged. On the occasions the next chance / community
chest card to be picked was an &quot;already owned&quot; &quot;Get out of Jail
free&quot; card it politely printed:</p>
<pre class="screen">
You have picked:
You have picked:
&quot;next card in the array&quot;
</pre>
<p>onto the ASR-33 Teletype (yep VDUs weren't around then - dates
me huh?).</p>
<p>Failure 2) For the computer's turn, when it landed on a site
that would complete a set, it would sell hotels and houses,
mortgage other sites up-to-the-hilt (including those in the
required site's colour-group) in order to purchase the final site.
Not a very good strategy.</p>
<p>Failure 3) It was fixed to only allow one player and the
computer to play the game.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e57" id="d0e57"></a>C</h3>
</div>
<p>Now out in the real world - but still green. At that time
programming in FORTRAN-IV and a bit in 'C', but because the usual
commercial deadlines, if a program worked one wasn't allowed to go
back and clean-up the design or the code.</p>
<p>Learning 'C' via 'on-the-job training' is all very well but only
a limited 'Fortran like' subset of the language got used. I wanted
to really understand structures, macros and other bits of the C
language that just weren't there in FORTRAN. I bought a copy of
Borland's TURBO-C, and succeeded in learning a lot more C.</p>
<p>Failure 1) The Monopoly implementation (which would have been
simple console I/O) never really got off the ground. I started to
read the Borland manuals about graphical interfaces and other
exciting stuff that would make the whole interface to the game much
more user-friendly. It changed my ideas about the user interface
and a redesign was beckoning.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e66" id="d0e66"></a>Stage 3: Windowed
C</h3>
</div>
<p>The objective this time was simply to have a much jazzier
interface, coloured boxes on the screen with coloured text in them
- not Windows as we know it today.</p>
<p>Borland C was still the mainstay of the development but Borland
Prolog also got purchased, which I was sure would be useful for the
decision making of the computerised players.</p>
<p>Success 1) Prolog was fun. I succeeded in writing a program to
solve the peg board game &quot;Solitaire&quot;. I also started writing a few
useful graphical library routines, painted a few &quot;Title Deed&quot; and
&quot;Chance / Community Chest&quot; cards on the screen.</p>
<p>Failure 1) Well - Solitaire isn't exactly Monopoly is it? But
then along came...</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e77" id="d0e77"></a>Stage 4: Microsoft
Windows</h3>
</div>
<p>Yep - here it was in all its glory... Windows/286! The
wonderful, colourful text-filled boxes now started looking somewhat
boring... and here was this mouse thing that could be used for an
even jazzier user-interface.</p>
<p>The objective here then was still to concentrate on improving
the user-interface. The trouble was the version of Borland C
wouldn't allow Windows programs to be built, because of a special
'prologue' piece of code inserted by the compiler at the start of
each routine.</p>
<p>So after wading through a few tonnes of documentation for the
newly purchased Microsoft C compiler and Software Development Kit,
my first Windows programs were being written.</p>
<p>Success 1) Obtained firm basis for the way Windows works &quot;behind
the scenes&quot;. Such things are hidden to today's developers by more
and more layers of programmatic interfaces.</p>
<p>Failure 1) As far as good old Monopoly was concerned... complete
failure! Windows required so many new ideas simply to experiment
with and understand there was no time for development. Dealing with
mouse movement, creating windows, updating menu etc all required
little experimental programs. But the hankering was still there. I
still wanted my Windows Monopoly program! (Persistent eh?)</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e90" id="d0e90"></a>Stage 5:
Object-Oriented</h3>
</div>
<p>Along came two things at once. Windows 3.0 (a vast improvement
on /286) and an object-oriented Windows development environment /
language called Actor!. I didn't really buy Actor! to learn OO
techniques, but because it promised quicker development of Windows
programs and it also ran under Windows V3.0.</p>
<p>Success 1) A good grounding for OO programming - understanding
&quot;objects&quot;, inheritance and polymorphism.</p>
<p>Success 2) Also the promise of faster development was delivered
because a completed version of the Monopoly program (without
&quot;computerised players&quot; though) was created.</p>
<p>Success 3) Learnt even more about Windows and had my first taste
of the benefits OO programming and some simple OO design
techniques.</p>
<p>Failure 1) Still hadn't completed the goal of having a Monopoly
program with computerised players.</p>
<p>Failure 2) A few things fairly essential to Monopoly (like
bartering of assets!) were lacking, but I was still pleased with
the result.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e105" id="d0e105"></a>Stage 6:
C++</h3>
</div>
<p>At this point the reasons behind the development of the pet
project became somewhat more commercially biased. I thought C++ was
going to be a more beneficial for my future career than Actor! I
was also interested to see how the OO programming techniques I'd
learned in Actor! were applied in C++.</p>
<p>This was back to Borland and their Turbo C++ version. The
integrated development environment was much better than Microsoft's
offering at the time.</p>
<p>Success 1) Another completed a version of the Monopoly
program.</p>
<p>Success 2) The user interface was even better. Little pop-up
windows containing &quot;For Sale&quot; or &quot;Sold&quot; signs were springing up
across the screen.</p>
<p>Success 3) The complete rules of the game were programmed -
assets could be bartered, various &quot;House rules&quot; that I've come
across from other people were allowed as program options.</p>
<p>Success 4) Understanding the C++ syntax and its view of OO
programming.</p>
<p>Failure 1) <span class="emphasis"><em>Still</em></span> hadn't
completed the goal of having a Monopoly program with computerised
players, but I was still really pleased with the result!</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e125" id="d0e125"></a>Stage 7: Visual
C++</h3>
</div>
<p>My reasons for going back to Microsoft are again, rightly or
wrongly, commercial. I suspected that (for PC based developments at
least) Visual C++ experience would be more advantageous than that
under Borland's IDE (sorry Borland).</p>
<p>So here I was re-learning the Windows interface through the use
of the Microsoft Foundation Classes.</p>
<p>Success 1) Commercially it paid off. I was able to use the
experience of Visual C++ to get on to a project at work that
otherwise I would never have been able to start.</p>
<p>Failure 1) Didn't complete the &quot;Microsoft-compatible user
interface&quot; version of Monopoly.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e136" id="d0e136"></a>Stage 8: Where I
am now!</h3>
</div>
<p>Stages 6 and 7 were definitely biased toward my career, but now
I'm back to my personal learning goals, even though they should
help my career as well.</p>
<p>It's all very well being able to write C++ programs and use many
of the features of the language, but it's just as important to
design classes that work together well, that are maintainable and
extensible. Although I believe my OO design to be good (don't we
all?), I still want to improve it further.</p>
<p>A review of the book &quot;Design Patterns&quot; [<a href="#GoF">GoF</a>]
interested me, and it was bought purely on the basis of the review
/ reviewer and, for anyone interested in design, I can certainly
recommend it.</p>
<p>I've been analysing the &quot;Patterns&quot; in the above book and asking
myself how they, if they or where they apply to the Monopoly
program.</p>
<p>Also (having 'completed' two programs) I have decided to start
'designing' the program from scratch so, in parallel with looking
at Patterns, I've been using UML with the demo version of Rational
Rose V4.0 that comes with &quot;UML Toolkit&quot; [<a href=
"#Eriksson-">Eriksson-</a>]</p>
<p>In part two I'll take a look at some of the classes in the
completed implementations and their dependencies on each other and
discuss what's wrong (or right) with them, also I'll take a look at
how the program performed certain tasks.</p>
<p>In part three I'll take a first stab at applying some Patterns
to the program design.</p>
<p class="c2"><span class="remark">John Merrells comments: I was a
student at Hatfield when the Dec-10 was melted down for precious
metals. The night before its final demise some of my fellow system
junkie friends logged an extensive session with the machine.
Recording a final conversation with this venerable beast as an
epigraph of is service. With this huge text file they spent many
hours constructing a perfect emulation of the fated machine. Before
departing to their prefabricated halls of residence, they left a
few terminals logged into the fake Dec-10. For days the ghost of
the Dec-10 would crop up in various corners of the computer center,
haunting the engineering population of Hatfield Poly.</span></p>
<p class="c2"><span class="remark">Unfortunately the system
administrator (otherwise known as the Angel of Death) decided that
this emulation was in fact an evil trojan horse designed to harvest
user passwords - sigh - so they hunted down the ghost of the Dec-10
and killed that too. (BOFH, for those of you who recall the early
days of usenet humor.)</span></p>
</div>
</div>
<div class="bibliography">
<div class="titlepage">
<h2><a name="d0e165" id="d0e165"></a>References</h2>
</div>
<div class="bibliomixed"><a name="GoF" id="GoF"></a>
<p class="bibliomixed">[GoF] <span class="citetitle"><i class=
"citetitle">Design Patterns - Elements of reusable
software</i></span> Gamma et al; Addison Wesley; ISBN
0-201-63361-2</p>
</div>
<div class="bibliomixed"><a name="Eriksson-" id="Eriksson-"></a>
<p class="bibliomixed">[Eriksson-] <span class=
"citetitle"><i class="citetitle">UML Toolkit</i></span> Eriksson
and Penker; Wiley; ISBN 0-471-19161-2</p>
</div>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
