sorry for the delay of my answer but I experienced problems with my e-mail lately. I reply also to the list because it may be of interest.
any comments are welcome :-)
I attach a paragraph from a paper I'm writing about it:
We can benefit from dynamic overloading in implementing other design patterns that involve two different class hierarchies, such as, e.g., the \emph{Strategy} pattern that ``defines a family of algorithms, encapsulate each one, and make them interchangeable'' \cite{Gamma}. The book \cite{Gamma} makes an example of use of this pattern for encapsulating the text formatting strategy for their document editor case study: one can use a simple text formatter for producing a draft copy of the document, while, for the final version, a more complex formatting policy can be adopted. While the need of dynamic overloading is not immediately evident from the structure of the pattern, its usefulness suddenly appears when one has to actually implement the formatting code: the document is stored in an aggregate structure where simple elements (characters, figures, etc.) have the same interface of aggregate ones (row, columns, etc.). This aggregate structure is indeed the pattern \emph{Composite}, that is usually used for implementing hierarchically structured information (recursive composition) and exploited in conjunction with patterns such as Strategy and Visitors and many others. Thus, the formmatter will have to behave differently according to the actual type of the document element that has to be formatted. Dynamic overloading will avoid using dynamic type checking and type casts.
Yves Roy wrote:
Lorenzo:
Could you explain to me how dd could be use in implementing strategy? Visitor, I understand, but I am curious to see an example with Strategy.
Yves
Lorenzo Bettini wrote:
I found double dispatch quite useful in implementing many design patterns (visitor, observer, strategy,...) so I'm posting this announce here too:
Hi
I've just released doublecpp:
Doublecpp is a preprocessor for C++ that handles a new linguistic construct for defining branches of a multi-method. The "right" branch of such a method will be selected dynamically at run-time according to the actual type of the object on which the method is invoked and to the actual type of the first argument: double dispatch.
http://www.lorenzobettini.it/software/doublecpp/index.html
Doublecpp is free software; you are free to use, share and modify it under the terms of the GNU General Public License (see COPYING).
Doublecpp is delivered with sources that have to be compiled. It can be downloaded from the following site:
http://www.lorenzobettini.it/software/doublecpp/doublecpp-0.2.tar.gz
Doublecpp has been developed using GNU gcc 3.2.2
You can build doublecpp also under Windows, using cygwin (http://www.cygwin.com). If you have problems with that, you can request the windows binaries directly to me.
IMPORTANT: you have to use a 3.x version of gcc: earlier versions have problems handling code generated by doublecpp.
You can find the documentation in the file
http://www.lorenzobettini.it/software/doublecpp/doublecpp.ps
I look forward to receiving comments!
-- +-----------------------------------------------------+ | Lorenzo Bettini ICQ# lbetto, 16080134 | | PhD in Computer Science | | Dip. Sistemi e Informatica, Univ. di Firenze | | Tel +39 055 4796741, Fax +39 055 4796730 | | Florence - Italy (GNU/Linux User # 158233) | | Home Page : http://www.lorenzobettini.it | | http://music.dsi.unifi.it XKlaim language | | http://www.lorenzobettini.it/purple Cover Band | | http://www.gnu.org/software/src-highlite | | http://www.gnu.org/software/gengetopt | | http://www.lorenzobettini.it/software/gengen | +-----------------------------------------------------+
_______________________________________________ gang-of-4-patterns mailing list [EMAIL PROTECTED] http://mail.cs.uiuc.edu/mailman/listinfo/gang-of-4-patterns