On Sat, Mar 7, 2009 at 11:36 AM, Rickard Öberg <[email protected]> wrote:
> Niclas Hedhman wrote:
>> On Fri, Mar 6, 2009 at 10:57 PM, Alex Shneyderman
>> <[email protected]> wrote:
>>> I am trying to develop a command line interface to my CRUD
>>> application. Command line is somewhat simple: cmd [param1 [param2]].
>>> Commands are registered as composites in application layer and will
>>> talk directly to the domain layer. To lookup my command composites I
>>> wanted to identify them by cmd tokens in assembly, since looking them
>>> up by type is a bit awkward.
>>>
>>> Is there no way to do identifiedBy for composites?
>>
>> Rickard's suggestion is workable, but I think not a recommended pattern.
>>
>> You should create a Factory (as Service) in the application layer that
>> produces the instances that you are after. That will also hide the
>> 'ugliness' of Composite instance creation, and nicely communicate what
>> arguments are required at compile time, instead of runtime exception
>> when missing required arguments are missing.
>
> And the implementation of the Factory could be as I outlined.

Yes, depends if the Factory knows "up-front" what types are available
or not. The former gives less complex code, but the latter provides a
"plug-in" mechanism.


Cheers
Niclas
-- 
http://www.qi4j.org - New Energy for Java

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to