> What's the best design pattern(s) to use if I have a set of similar objects > where I might want to, but not always, convert some of their internal > member data. > > e.g. I will want to take a set of similar objects that encapsulate internal > collections and convert timezone related data items within those internal > collections based on a the timezone that a requesting user lives in. >
A lot of the solutions would depend on your current design, for example are the similar objects inherit from a common base class or share the implementation of a common interface? Do you want to return a DateTime or some other wrapped object? One pattern that springs to mind if you do share some commonalities and client code uses those common classes (base classes or interfaces) would be to use a decorator pattern wrapping and delegating control to the inner object performing transparent conversion to and from the target object(s). Dealing with a common base class/interface calling code would be none the wiser, they'd just get a wrapped object if it was required. Alternatively the decorator pattern could also be applied to the objects in the collection returning decorated objects that perform the time zone conversions transparently. A factory could be used to create the similar objects or collection objects applying decorators if a timezone conversion is required. Cheers, Duncan =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: Essential .NET: building applications and components with C# November 29 - December 3, in Los Angeles http://www.develop.com/courses/edotnet View archives and manage your subscription(s) at http://discuss.develop.com
