On 2009-11-17 20.58, Pawel Niemiec wrote:
Assume I have two mixins with the same method's signature. Assume
that my human wants to speak().
I could do in particular do so: HumanComposite humanDeveloper =
(HumanComposite)new DeveloperMixin(); Or HumanComposite
humanDeveloper = (HumanComposite)new AlumniMixin();
That's usual polymorphic declaration. I was wondering if there were
possible to achieve let's say "horizontal" polymorphism with a help
of factories that are provided by Qi4j or other Qi4j mechanism that I
don't know, but as you say it's impossible to have same signatures'
names of methods in a same composite.
Well, that you could do by using a HumanComposite with the declaration
of speak(), but no mixin, and then extend it with AlumniComposite and
DeveloperComposite that declares the specific mixin. Then when speak()
is invoked you get the respective ones. So that would work fine.
The main question is whether you'd want to though. For my own cases I
find that I want to avoid polymorphism as much as possible, even
completely, but that depends on the usecase. One of the key points that
Trygve makes about the DCI thinking is to try and avoid polymorphism, so
that whenever you invoke a role method you can know and predict what
it's going to do.
/Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev