jfaiga (6) [Avatar] Offline
#1
Hi Mark,

In your book, you mention that the TimeProvider is a classic example of a cross cutting concern, and therefore you used it as an Ambient context pattern.

However you also mentioned that you wanted to remove mentioning the Ambient context pattern from the book.

Please could you show an example of how using the TimeProvider example as a Decorator?

Thanks
mark.seemann (383) [Avatar] Offline
#2
Re: TimeProvider using Decorator
A Decorator wouldn't make much sense because when you need to know the time, it's essentially a Query (in the CQS terminology) and you can't query a Decorator from within the decorated class.

Instead of an Ambient Context, I prefer simply to inject some sort of ITimeProvider dependency into those classes that need it.
jfaiga (6) [Avatar] Offline
#3
Re: TimeProvider using Decorator
Thanks!