| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
I've got a question about the Decorator Pattern. Is the purpose of the Decorator Pattern to extend functionality of an already given method of an component? Or can/does it allow additional methods to be added to certain instances of a component?
For example, all of the examples I've seen so far (and I can't read C++ very well....) simply extend append functionality to a method of an instance. E.g. ActionScript Code:
However, can and do concrete decorators add additional functionality or does this call for a different design pattern. ActionScript Code:
My guess is decorator is used only to extend functionality of a method already in the component. 1 More Question: What is the point of the abstract decorator class? In my example above you can see I left it out. But with something like this from here ActionScript Code:
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman Last edited by Flash Gordon; 08-18-2007 at 09:49 PM.. |
|
|
|
|
|
#2 |
|
lala
Join Date: Feb 2002
Location: on the road
Posts: 2,859
|
decorater does both the things you asked originally.
then that c++ class is an abstract class so you cannot use it HAS to be extended. |
|
|
|
|
|
|
|
|
#3 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
cool. thanks for the reply. I got that book you mentioned and it is soooo much better than the AS 3 design patterns.
![]()
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#4 |
|
lala
Join Date: Feb 2002
Location: on the road
Posts: 2,859
|
i have a perma copy on my desk ![]() |
|
|
|
|
|
#5 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
Yea, it's good stuff!
However, I've read both books and some online stuff, and I'm just not clear what purpose the Abstractor Decortator server. When even have it? Why not directly subclass from the Abstract Component?
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#6 |
|
as[org].addListener(this)
Join Date: Dec 2005
Location: LA, California
Posts: 838
|
http://www.schelterstudios.com/blog/?p=28
http://www.schelterstudios.com/blog/?p=29 Two blog entries I wrote about decorators in AS 3 The abstract decorator should have additional logic that you need to create decorators that the abstract component alone wouldn't have, such as the ability to aggregate other instances into itself. Last edited by Assertnfailure; 08-20-2007 at 10:16 PM.. |
|
|
|
|
|
#7 |
|
...
Join Date: Mar 2005
Posts: 248
|
What book is it that you're using? I'd really like to learn more about patterns and tested development solutions and practices.
|
|
|
|
|
|
#8 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
Head First Design Patterns By O'Reilly. It is a Java book
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
|
|
#9 |
|
lala
Join Date: Feb 2002
Location: on the road
Posts: 2,859
|
are you slaggin my fav DP book? i will take offence :s
|
|
|
|
|
|
#10 |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
Nah, that book is great! I read about 1/2 the book in a week. One of the best books I've read. Thanks for the heads up about it.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|