Use for the Decorator pattern?

59 views
Skip to first unread message

John Whish

unread,
Jun 19, 2012, 5:25:52 AM6/19/12
to coldfu...@googlegroups.com
Hi,

I'm stuck in a design pattern quandry :)

The scenario I have is that I want to get some metrics from the CFML server, but I want to run on Adobe ColdFusion and Railo (and maybe Open BD in the future). Adobe ColdFusion has some additional metrics available which don't seem to be available in Railo.

For example: Railo and ColdFusion both allow me to get the version of Java that I'm running on so "getJavaVersion" is a common method for both Engines, whereas getRequestsTimedout() is only available in ColdFusion.

So my question is; would you:

a) Create one base class which you then inherit from and add in the extra ColdFusion methods (seems brittle to me)
b) Create one common class that contains the getJavaVersion() method and then decorate that class with a "ColdFusionMetrics" class that contains the getRequestsTimedOut() (AFAIK decorator pattern is really for modifying behaviour rather than adding behaviour).
c) Create an interface which defines common methods and make RailoMetrics and ColdFusionMetrics classes which impliment the interface.
d) Something else clever I haven't thought of
e) Rock back and forth in a darkened room trying to figure this out

Sorry if I haven't explained it very well  - thanks for reading!

John

John Whish

unread,
Jun 19, 2012, 6:15:47 AM6/19/12
to coldfu...@googlegroups.com
Thinking and reading up a bit more, I've found an example of
decorators adding new functionality in the Head First Dsign Patterns
book rather than just modifying the behaviour, also Transfer ORM used
decorators so, I think that's the way I'll go. I'm using the strategy
pattern to add the behaviour to another class, but wasn't sure how to
handle the shared / unique behaviour.
> --
> You received this message because you are subscribed to the Google Groups
> "Object-Oriented Programming in ColdFusion" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/coldfusionoo/-/a8uGWsTR_y0J.
> To post to this group, send email to coldfu...@googlegroups.com.
> To unsubscribe from this group, send email to
> coldfusionoo...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/coldfusionoo?hl=en.
Reply all
Reply to author
Forward
0 new messages