You are here: Re: the Visitor Design Pattern « PHP Programming Language « IT news, forums, messages
Re: the Visitor Design Pattern

Posted by FluffyCat on 10/27/14 11:33

Ok, excellent stuff to think about. The problem with doing these
examples is that there is a huge difference between getting your code
to run and having a good example of a pattern.

I did add a function to my testVisitor that will take in any Visitee
and Visitor and call $visitee->accept($visitor), and so adds a bit
more polymorphism to the mix.

I'm still not convinced this is necessary for a viable Visitor
example, but if it helps to make things seem at all clearer I'm
totally into it.

I would have preferred, as was suggested, to give the Visitor some
special access to Visitor. However, I don't see how to do this with
PHP. In C++ you can set up friend (?) classes. In Java you can have
package level access. As is stated in GoF, "the pattern often forces
you to provide public operations to access the element's internal
state, which may compromise it's encapsulation". I guess you could
say that Visitor Pattern is a way to add a new operation to a class
with out altering the class - but without the advantage of having any
special class access.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация