Building an Extensible Menu Class - What's On The Menu? (
Page 3 of 10 )
So that's the
theory. Let's now spend a few minutes discussing the rationale behind the Menu
object I plan to build.
Conceptually, a Web site can be considered as a
combination of two things: menus and content. Menus are used to organize and
classify the type of content, and to offer one or more navigational paths to
specific content modules.
Now, although a menu may be visually presented
in a number of different ways, there are certain common elements present in
every menu:
1. Most menus are broken into levels, with each level more
focused than the last; this hierarchical structure is sometimes referred to as a
"menu tree".
2. Every menu tree consists of nodes connected to each other
by branches.
3. A node may have one or more children, but can have only
one parent.
Using these common principles, it is possible to build a Menu
object which exposes certain generic methods. These methods will have nothing to
do with the visual presentation of the menu tree; rather, they provide a simple
API to various menu attributes and relationships, and can be used by client- or
server-side scripts which are more closely connected to the presentation layer.