Reply to Re: Learning patterns... Decorator

Your name:

Reply:


Posted by Tyno Gendo on 09/28/07 09:23

Willem Bogaerts wrote:
>> Are you sure I was subclassing? I thought I would have to use
>> 'extends' to subclass.
>
> An interface is a purely abstract class. The syntax is different, but
> you are still subclassing a (very) generic thing.

yes, i was reading that 'programming to an interface' really means an
interface or abstract class.

> The GOF book speaks about "adding responsibility dynamically". The
> CLargeProduct class does not add anything dynamically ("at runtime") and
> the responsibility is to hand out a value. I don't think a product class
> should even be aware of the existence of a database.

I wasn't thinking of putting any database login in the decorator itself,
rather this would be done separately and i wouldn't specifically have
such a thing as CWhiteProduct, rather it would be CColourDecorator that
would apply the 'adjusted' cost for the painting job.

I actually found this article now:
http://www.devshed.com/c/a/PHP/Working-with-MySQL-Result-Sets-and-the-Decorator-Pattern-in-PHP/

I think I see what you mean, this does use 'extends' but doesn't add any
new methods and uses same parent calling technique, so is
decorat/subclass a very subtle difference, ie. if you add a new method
not in the parent, it then basically becomes sub-classing?

The thing I'm trying to get to really is how the database data should be
structured and how the actual PHP code would utilise 'attribute' values
such as 'white' and how the code would be structured in the PHP to then
'decorate' my product to find it's real value.

eg. website may have 'Coat' product, might have drop-down 'White',
'Furry', in the db white may cost 1.00 more, if you want it furry, might
be an extra 2.00

what is an object orientated approaching to extracting and processing
this against a base 'product' object??

normally you'd be using switch and if's and things to do things if 'some
attribute' is returned in a dataset, but i want to practice getting rid
of big switch/if type structures.

[Back to original 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

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