Object Hierarchies
The previous method of adding attributes may be acceptable for simple classification, but it just doesn't scale well for future growth. Say the requirements specified numerous levels of classification. Adding new attributes to represent new subcategories, plus any other attributes supporting each subcategory, can greatly increase the complexity of a project.
What's happening with subcategories is that a natural hierarchy is being created. Object-oriented programming provides the methodology to manage natural hierarchies. If the project specifies the categorization of animals, it may be logical to place an animal object at the top of the hierarchy. At the next level would be birds, mammals, and reptiles. Under birds would be ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access