c# - How far to go overriding methods, properties, ... of a base class e.g. .net TreeNode class -
I am working on some application, which uses a TreeView control to represent business objects The link between business objects and tree nodes is maintained through the tag property of the treeoid I am not very happy with this, because I think the link is not "tight", for example a TreeNo without a business object De object may be, I want to update the tree image on the basis of business object state. That's why I made my own special treeoid class from TreeNode:
With this minimal approach, I call every property or method of the base class when I give the tree node object in the "actiontire node. The solution will be to override / overwrite every method or property and will return an object of type ActionTreeNode. What do you think, is it more appropriate to take a minimal perspective or will you try to complete all the methods, properties to avoid molding? Thank you.
I like the least approach if you have clutter with loads of loaded statements in your code If you are worried about, just make a method to do this in one place:
GetParent (ActionTreeNode node) {return node.Parent as ActionTreeNode; } // In some method: ActionTreeNode parent = GetParent (someNode); If (parents! = Void) {/ Parent an ActionTreeNode} Do not forget the empty check at the return value, however parents should not have actiontransm ...
Comments
Post a Comment