Actually, since the "root" node is a special case of node, you probably need RootHtmlPageNode: HtmlPageNode.
Another idea: since you are not indicating what the difference is between the βrootβ and the βnormalβ node, maybe just a flag in the node that determines whether it is root or not will also be a good design.
EDIT: According to your explanation, there is no functional difference between the normal and the root node, so a simple flag (or the IsRootNode property) is enough. If the "root" node provides only styling data (or any other data for yourself and your children), you can put this style data in a separate structure / class and render it recursively (based on IsRootNode):
class Node { private bool isRootNode; public bool IsRootNode; private StylingData stylingData; public StylingData StylingData { set { if (this.IsRootNode) this.stylingData = value; else throw new ApplicationException("The node is not root."); } get { if (this.IsRootNode) return this.stylingData; else return this.parent.StylingData; } } }
This assumes that each node has a parent reference to it.
This is beyond the scope of the question since I do not know the exact design.
Sunny Milenov Sep 17 '08 at 15:16 2008-09-17 15:16
source share