I have two instances in the application where I need to implement functionality to convert an object from one type to another. One, to go from a domain object to another domain object, the other to go from a domain object to XmlDocument.
First I set it to include ToXml() and ToMyOtherDO() within DomainObject1 and DomainObject2 respectively.
ToXml functionality is not very specific for the implementation of DomainObject1 and probably can live anywhere. ToMyOtherDO() has functionality very specific to the type in which it lives. Both perform type conversions, but are completely different.
My question is: have I put this functionality in the right place? Would this functionality fit better in a helper class? Or some place - perhaps overriding the explicit casting operator?
source share