Re: [morph-developer] appendDefaultComponents WAS Re: Copying Objects to Maps
Brought to you by:
orangeherbert,
sgarlatm
|
From: Matt S. <Mat...@wh...> - 2007-02-28 15:58:12
|
Thinking further about option #1, how about this logic
class SDT {
boolean appendDefaultComponents=true;
...
getComponents() {
if (appendDefaultComponents) {
return concat(components, getDefaultComponents());
}
else {
if (isEmpty(components))
throw new MorphException("No components found");
return components;
}
}
Matt S
Matt Benson wrote:
> On option 1 below: first issue: it seems that it
> would be difficult to differentiate when to add what,
> especially when no user-supplied components are
> provided. second issue: it seems like this would
> still cause problems with composites, wouldn't it? :(
>
> -MJB
>
> --- Matt Sgarlata
> <Mat...@wh...> wrote:
>
>
>> That sounds like a reasonable approach.
>>
>> Here is some brainstorming on other approaches:
>> 1) Modify the getComponents method instead of the
>> setComponents method
>> to code the behavior of appendDefaultComponents
>> 2) Introduce a new property like
>> nonDefaultComponents that must be used
>> when you want to appendDefaultComponents.
>> Configuration is then done
>> either with appendDefaultComponents = true and
>> modifications done to
>> nonDefaultComponents or when
>> appendDefaultComponents=false directly to
>> the components property.
>>
>> #2 definitely seems like a kludge and not a very
>> good solution to me.
>> Did you try out #1?
>>
>> Matt S
>>
>> Matt Benson wrote:
>>
>>> I had implemented this for
>>> SimpleDelegatingTransformer, was working on
>>> duplicating the effort for
>>>
>> SimpleDelegatingReflector,
>>
>>> and managed to break several test cases. I was
>>> setting a flag and--if true--appending default
>>> components every time components were set via
>>> setComponents(). Debugging made it obvious that
>>>
>> this
>>
>>> completely circumvents the point of having these
>>> classes be composites; i.e. they are no longer
>>> specializable. So I'd like to discuss what the
>>> options are for enabling this simplified
>>>
>> configuration
>>
>>> without breaking existing specialization
>>> (SimpleDelegatingTransformer should in theory
>>>
>> suffer
>>
>>> from the same situation, only none of the core
>>>
>> code
>>
>>> happens to specialize an SDT):
>>>
>>> I think in order to do this safely the easiest
>>>
>> thing,
>>
>>> at least to start with, is to simple provide a
>>> constructor that allows the user to specify the
>>> component list and accepts appendDefaultComponents
>>>
>> as
>>
>>> a boolean parameter on a one-time-only basis. I
>>>
>> have
>>
>>> made this change to SimpleDelegatingReflector and
>>>
>> will
>>
>>> go ahead and modify SimpleDelegatingTransformer
>>> similarly. This at least provides for the
>>>
>> behavior at
>>
>>> the cost of forcing the user to use constructor
>>> injection (assuming Spring config). Perhaps we
>>>
>> will
>>
>>> then be able to see better how to proceed.
>>>
>>> -Matt
>>>
>>> --- Matt Sgarlata
>>> <Mat...@wh...> wrote:
>>>
>>>
>>>
>>>> Matt Benson wrote:
>>>>
>>>>
>>>>> Hmph--hadn't noticed the Spring file. :) This
>>>>>
>> is
>>
>>>>> something I would like to think more about for
>>>>>
>> the
>>
>>>>> long-term. I've been looking at this stuff for
>>>>> several hours today (and once more revisited the
>>>>> UNfruitful path of having SDT flat-out implement
>>>>> NodeCopier, though I almost got there) and now I
>>>>>
>>>>>
>>>> think
>>>>
>>>>
>>>>> a tiny piece of effort that would have quite a
>>>>>
>> bit
>>
>>>>>
>>>>>
>>>> of
>>>>
>>>>
>>>>> yield would simply be a boolean
>>>>> appendDefaultComponents flag for SDT. This
>>>>>
>> would
>>
>>>>> greatly simplify Spring (or otherwise)
>>>>>
>>>>>
>>>> configuration
>>>>
>>>>
>>>>> of an application's top-level SDT where the
>>>>>
>>>>>
>>>> developer
>>>>
>>>>
>>>>> provides custom transformer implementations, but
>>>>>
>>>>>
>>>> wants
>>>>
>>>>
>>>>> to defer to Morph's default behavior for
>>>>>
>> standard
>>
>>>>> cases. Hopefully this would cover >= 90% of
>>>>>
>> what
>>
>>>>> developers would want to do, while still leaving
>>>>>
>>>>>
>>>> the
>>>>
>>>>
>>>>> door open for more complex configurations.
>>>>>
>>>>> "Make easy things easy and hard things
>>>>>
>> possible."
>>
>>>>>
>>>>>
>>>>>
>>>> Yes, it is a huge pain in the neck to customize
>>>>
>> the
>>
>>>> SDT because of the
>>>> need to exactly duplicate the default
>>>>
>> transformers
>>
>>>> that come with Morph
>>>> and make sure the custom transformers come before
>>>> the built-in ones. I
>>>> hadn't really considered adding a boolean flag
>>>>
>> like
>>
>>>> this, and I do agree
>>>> it would be a very minor change with a very large
>>>> benefit. I would also
>>>> be in favor of the default value for the flag to
>>>>
>> be
>>
>>>> true. I believe
>>>> SimpleDelegatingReflector would also benefit from
>>>>
>> a
>>
>>>> similar change.
>>>>
>>>> Matt S
>>>>
>>>>
>>>>
>>>>
> -------------------------------------------------------------------------
>
>>>
>>>
>>>> Take Surveys. Earn Cash. Influence the Future of
>>>>
>> IT
>>
>>>> Join SourceForge.net's Techsay panel and you'll
>>>>
>> get
>>
>>>> the chance to share your
>>>> opinions on IT & business topics through brief
>>>> surveys-and earn cash
>>>>
>>>>
>>>>
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
>>>
>>>
>>>> _______________________________________________
>>>> morph-developer mailing list
>>>> mor...@li...
>>>>
>>>>
>>>>
> https://lists.sourceforge.net/lists/listinfo/morph-developer
>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
> ____________________________________________________________________________________
>
>>> Do you Yahoo!?
>>> Everyone is raving about the all-new Yahoo! Mail
>>>
>> beta.
>>
>>> http://new.mail.yahoo.com
>>>
>>>
>>>
> -------------------------------------------------------------------------
>
>>> Take Surveys. Earn Cash. Influence the Future of
>>>
>> IT
>>
>>> Join SourceForge.net's Techsay panel and you'll
>>>
>> get the chance to share your
>>
>>> opinions on IT & business topics through brief
>>>
>> surveys-and earn cash
>>
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
>>> _______________________________________________
>>> morph-developer mailing list
>>> mor...@li...
>>>
>>>
> https://lists.sourceforge.net/lists/listinfo/morph-developer
>
>>>
>>>
> -------------------------------------------------------------------------
>
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get
>> the chance to share your
>> opinions on IT & business topics through brief
>> surveys-and earn cash
>>
>>
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV>
> _______________________________________________
>
>> morph-developer mailing list
>> mor...@li...
>>
>>
> https://lists.sourceforge.net/lists/listinfo/morph-developer
>
>
>
>
>
> ____________________________________________________________________________________
> Cheap talk?
> Check out Yahoo! Messenger's low PC-to-Phone call rates.
> http://voice.yahoo.com
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> morph-developer mailing list
> mor...@li...
> https://lists.sourceforge.net/lists/listinfo/morph-developer
>
>
|