From charlesreid1

Tree data structures provide a great application of many object-oriented programming principles.

Abstract class interfaces allow you to impose a uniform interface for different tree types or tree implementations, and have it all be transparent to the user.

Template method pattern is a pattern that involves creating functional hooks (before/after hooks), so-called "template methods". These are useful for doing things like customizing a tree traversal.

Generic type/template interfaces are useful for storing arbitrary data in trees - templated tree node classes are useful because the data stored in the tree is not usually material to the schema of the tree itself.

Comparison operator implementation and overloading comparison operator behavior for objects is also extremely useful to be able to do, as it allows you to perform comparisons to store sorted trees.

Exceptions are a must. Proper exception handling, and good exception-handling practices, can be practiced with trees.


See also: OOP Checklist

Flags