Hi, I'm working on a tree widget and decided to apply the composite pattern. Therefore I've the following classes: - TreeNode (abstract) - LeafTreeNode - CompositeTreeNode
CompositeTreeNode has additional methods on top of TreeNode (LeafNode) like .getChildNodes(), .open(), .close() etc. The problem arises when the user decides to add a new node to a LeafTreeNode. If this happens all the CompositeTreeNode properties should be applied to the given node. An elegant solution would be to change the node object's class dynamically. Something like this: this.implement( CompositeTreeNode ); How can I achieve this? Thanks, Zsolt
