问题
I'm designing a web site navigation hierarchy. It's a tree of nodes. Nodes represent web pages.
Some nodes on the tree are special. I need a name for them.
There are multiple such nodes. Each is the "root" of a sub-tree with pages that have a distinct logo, style sheet, or layout. Think of different departments.
site map with color-coded sub-trees http://img518.imageshack.us/img518/153/subtreesfe1.gif
What should I name this type of node?
回答1:
How about Root (node with children, but no parent), Node (node with children and parent) and Leaf (node with no children and parent)?
You can then distinguish by name and position within the tree structure (E.g. DepartmentRoot, DepartmentNode, DepartmentLeaf) if need be..
Update Following Comment from OP
Looking at your question, you said that "some" are special, and in your diagram, you have different nodes looking differently at different levels. The nodes may be different in their design, you can build a tree structure many ways. For example, a single abstract class that can have child nodes, if no children, its a leaf, if no parent, its a root but this can change in its lifetime. Or, a fixed class structure in which leafs are a specific class type that cannot have children added to them in any way.
IF your design does not need you to distinguish nodes differently depending on their position (relative to the root) it suggests that you have an abstract class used for them all.
In which case, it raises the question, how is it different?
If it is simply the same as the standard node everywhere else, but with a bit of styling, how about StyledNode? Do you even need it to be seperate (no style == no big deal, it doesn't render).
Since I don't know the mechanics of how the tree is architected, there could possibly be several factors to consider when naming.
回答2:
The word you are looking for is "Section". It's part of a whole and has the same stuff inside.
So, you have Nodes, which have children and a parent, and you have SectionNodes which are the roots of these special subtrees.
回答3:
How about PageTemplate to embody the fact that its children have their own layout, CSS etc?
回答4:
AreaNode
回答5:
So, it sounds like you are gathering categories. The nodes are the entry points of this categories. How about "TopCategoryNode", "CategoryEntry" then for som,ething that is below them. Or, if you want to divide more, something like "CategoryCSS", "CategoryLayout" etc?
This is kind of generic, but you make clear that there are "categories", and that these do consist of more than one subnode, or subtheme.
回答6:
Branch ?
Keeps the tree analogy and also hints in this case at departments etc
Thinking about class heirarchies, Root is probably a special case of Branch, which is a special case of Node, special case of Leaf. The Branch/Node distinction is one you get to make for your special situation.
来源:https://stackoverflow.com/questions/86790/is-there-a-specific-name-for-the-node-that-coresponds-to-a-subtree