Timeline for Is this a pattern? Proxy/delegation of interface to existing concrete implementation
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 12, 2012 at 16:58 | history | edited | DXM | CC BY-SA 3.0 | added 891 characters in body |
| Jun 12, 2012 at 16:56 | comment | added | Ian Newson | I had come across the decorator pattern before, but considered it to be slightly different as mostly I've seen it used to implement an existing interface by using several other implementations, normally to gain the benefit of composability. My intention is more to 'subvert' an existing implementation. However, the coffee example at the bottom of the Wikipedia page convinced me that it's one and the same pattern. Thanks! | |
| Jun 12, 2012 at 16:53 | vote | accept | Ian Newson | ||
| Jun 12, 2012 at 16:02 | comment | added | pdr | Take your point, but I'm still thinking that it falls under the Proxy pattern. Your description of a Proxy only really covers one of the four types listed here: oodesign.com/proxy-pattern.html Decorator, to my mind, implies something where you can, at runtime, wrap one or many layers of decoration around an object. The OP's example is specifically a design-time thing. | |
| Jun 12, 2012 at 15:49 | comment | added | DXM | @pdr: UI is a typical example and the word "decorator" might be misleading, but same idea can be applied to anything. From Wiki: "By contrast, decorators are objects, created at runtime, and can be combined on a per-use basis. The I/O Streams implementations of both Java and the .NET Framework incorporate the decorator pattern." | |
| Jun 12, 2012 at 15:48 | comment | added | pdr | Still, Decorator is a UI pattern. I don't think it fits this example. | |
| Jun 12, 2012 at 15:45 | comment | added | DXM | @pdr: Can you define "it"? From OP: "but I need to change a small part of the behaviour". Pretty sure that's exactly what decorator does. | |
| Jun 12, 2012 at 15:43 | comment | added | pdr | But it's not changing behaviour, is it? | |
| Jun 12, 2012 at 15:40 | history | answered | DXM | CC BY-SA 3.0 |