From: Matt B. <gud...@ya...> - 2007-02-05 18:11:59
|
I am reawakening this thread. I touched on this subject during the original discussion, but at the time I couldn't quite articulate what was bothering me about the whole business. Last Friday it burst upon me, and I have continued to kick it around over the weekend but have not been able to refute my own logic: Basically with InstantiatingReflector taking a source parameter, it IS a converter. What is the difference between: InstantiatingReflector.newInstance(Class, Object) -and- DecoratedConverter.convert(Class, Object) ? >From my POV, nothing. Different semantics for what, using the method parameters as an indicator, is one concept. The role of the InstantiatingReflector in the Morph library is to adapt a copier to the converter interface, using the following algorithm: 1. Create a new instance I 2. Invoke copy() using I as the destination object. This sequence of operations amounts to a "derived conversion": one which relies on a parent conversion to supply the target object, then modifies the resulting object. This modification will always consist of making changes on a target object based on the source object (otherwise the parent converter alone would suffice), and thus infallibly corresponds in intent with Copier.copy(). This proves that a DerivedConverter is precisely a Copier that implements Converter by first delegating to a parent Converter, then copies the source to the resulting destination object. The parent converter can be overridden, but would default to an, e.g., NewInstanceConverter which simply creates a new instance of the destinationClass. In adopting the DerivedConverter concept, InstantiatingReflector would, in my opinion, no longer be needed, and would hopefully be deprecated and then removed as soon as the current players on the mailing list(s) are all up to speed. Because the interfaces are so similar, I would expect the refactoring of a custom InstantiatingReflector implementation to a custom Converter implementation to be trivial. I invite discussion, but I really think I have something here. Impatiently awaiting comment, Matt B ____________________________________________________________________________________ We won't tell. Get more on shows you hate to love (and love to hate): Yahoo! TV's Guilty Pleasures list. http://tv.yahoo.com/collections/265 |