Hello,
> 2) if you really need to distinguish based on type rather than behavior
> (e.g. a Tree Node and a Tree Leaf presumably implement the same interface),
> the simplest workaround is to add a dedicated property to the trait to
> distinguish between these types, for instance, add an { isLeaf: <boolean> }
> property.
Actually, in my case Tree Leaf would be Trait, so I would check
behavior rather than type. isLeaf seems a good solution, though.
In perfect case, Trait would check if used properties belong to
particular trait only when creating a real object (I mean Trait.create
method), and at run-time (when using crated objects), properties
existence would be presumed (because of performance). Although,
currently I do not see the way to do it.
If you'll have some other ideas, please share it. And thanks for
response!