1

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?

4

6 回答 6

6

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.

于 2008-09-17T19:40:02.733 回答
2

您要查找的词是“部分”。它是整体的一部分,里面有同样的东西。

所以,你有节点,它有子节点和父节点,你有 SectionNodes,它们是这些特殊子树的根。

于 2008-09-17T19:44:35.953 回答
1

所以,听起来你正在收集类别。节点是该类别的入口点。那么“TopCategoryNode”、“CategoryEntry”怎么样呢?它们下面的东西。或者,如果你想划分更多,比如“CategoryCSS”、“CategoryLayout”等?

这是一种通用的,但您明确表示存在“类别”,并且这些类别确实包含多个子节点或子主题。

于 2008-09-17T19:46:37.790 回答
1

分支 ?

保持树类比,并在这种情况下暗示部门等

考虑类层次结构,Root 可能是 Branch 的一个特例,它是 Node 的一个特例,Leaf 的一个特例。分支/节点的区别是您可以针对您的特殊情况做出的区别。

于 2008-09-17T19:46:49.037 回答
1

How about PageTemplate to embody the fact that its children have their own layout, CSS etc?

于 2008-09-17T19:43:17.127 回答
1

AreaNode

于 2008-09-17T19:43:24.303 回答