On Mon, Feb 23, 2009 at 9:38 PM, Anders Norås
<[email protected]> wrote:

> I'm currently working on a demo for a talk where I'm using Qi4j to
> illustrate how one can do protoype based development with Java. For
> reference, I'm including a Ruby example of this taken from the talk;

My Ruby knowledge == zero, so the code doesn't say me much...

> Is there an easy way (not so easy ways are also fine :-) to achieve
> this?

We don't allow you to change the Mixins of composites on the fly.
Every combination must be declared, either statically or at
deploy-time (which we generally don't recommend).

So the alternative behaviour would sit in a different 'type',
potentially sharing everything except a Concern that constructs the
fullname depending on (for instance) a internal mixin set at
builder-time (use the stateFor() method with a e.g. FormatType type
holding the formatting variants).

So, I think the example is probably not a good showcase of dynamically
changeable mixins, and we happen to think that there are very few
showcases, and the downsides will quickly negate the benefits of a
non-static system.

Mind you, you can theoretically have a JRuby script implementing your
Qi4j mixin, and modify the script on the fly for a different behavior
if you want to get really sassy about it. Self-modifying code is
definitely beyond our recommendations. While you are at it, put a
couple of Mixins together in the same Composite, each implemented in
different language; Groovy, JavaScript, Beanshell and Ruby. (Lacking
Skala!)


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