Professional Documents
Culture Documents
================================================================================
In the spirit of contributing to the design pattern community (whilst learning
more about patterns), I followed Mark McFadden�s example of converting the Java
examples associated with �Head First Design Patterns� to another computer
language: C++.
First, I would like to acknowledge the good work done by the authors of this
book and their support of my efforts. Second, I do not claim to be a Java
developer, so I may have misinterpreted a subtle Java notion or convention
during the conversion process. In this regard, I welcome (constructive) feedback.
Finally, I intend to provide three levels of interpretation (Bronze, Silver & Gold)
on two different platforms (Windows & Linux):
Conventions:
================================================================================
A note about style:
This convention revealed itself while I was creating the 'Bronze' version; when
my charter was maintain the original example and minimize any code changes. That
is,
I simply wanted it to compile and run. I understand that adopting the Java
convention
is a deviation from common C++ practices and some may balk at it (even ridicule
it);
however, I have grown to appreciate its simplicly and explicite clarity.
BRONZE
================================================================================
A 'syntactical' translation; simply get it to compile, run and produce the same
output as the Java examples with minimal changes. No regard was given for memory
leakes or class integrety.
version 1.0:
------------
Adapter:
* Duck and Turkey test drives' where combined into ducks.cpp and implemented by
defining (or not defining) the pre-processor definition: _DUCK_ADAPTER_
Factory:
* Original Pizzaaf has a logic error, it does not cut Chicago Style pizza's in
squares.
Iterator:
* Renamed �Menu� to �Menus� to avoid a conflict between the project name and one
of its header files.
* MenuIterator was initially attempted but dismissed for the following reasons:
Proxy:
* Deferred, pending suitable solution for GUI (most likely it will be a WTL
implementation.)
SILVER
================================================================================
The Silver version is 'volatile'! That is, it will continue to morph more and more
into what is termed 'Good C++ programming practices'. As stated, the 'Bronze'
version is a 'syntactical' translation only; however, it was also the foundation
for this version, which presented a dilemma: rework existing examples to implement
recognized C++ style, or provide more pattern examples, so its my intent to work
on patter examples and rework the code as I go.
version 1.0:
------------
version 1.2:
------------
version 1.3:
------------
I deviated from the example in the book for two reasons: I wanted to 'sort'
ducks as illustrated in the 'Template Method' pattern and since that illustration
sorted by 'weight' I thought naming the example 'Fowlweight' combined both the
pattern and its intent. Since I deviated, I felt obligated to write a narrative
in the same tone as that used throughout the book. Here is my humble attempt:
version 1.4:
------------
Possible enhancements:
- add other keywords, such as 'for', 'if'
- add 'turkey' via adapter
version 1.5:
------------
version 1.6:
------------