Cascade calls with addChild()

Is it a good idea to make addChild() return the node which has been added ? So you could do like that :


scene.addChild(objTranslate).addChild(objRotate).addChild(objScale).addChild(model);

That’d be very, very convenient.

Hmm, what about returning the object itself ?


scene.addChild(objTanslate.addChild(objRotate.addChild(objScale.addChild(model))));

in that version, addChild() works like stringbuffer for example.

Extended to other methods that would also allow multiple method invocation on the same object like :


objTranslate.setTransform(trans).addChild(objRotate.setTransform(rot).addChild(objScale.setTransform(scale).addChild(model))));

(kidding)

Lilian :slight_smile:

Hmm I don’t like the four parenthesis at the end of the line… not clear at all.

:o :o :o Wow wow wow what a big mess that’s not clarification, that’s obscurification…

Yeah i was kidding…

One thing for sure is that Xith code is bloated for simple cases, like tutorials.

Hopefully it’s much better and cleaner when used in larger projects.

Lilian

I’m working on that… and that something like cascade calls that unbloat the whole… unfortunately not keeping the same strictness and cleanness of the architecture.