What is the class hierarchy?

A class hierarchy, which is also called a class taxonomics, is a group of related classes that are connected by heritage to do similar things. The upper part of the hierarchy can be the only basic class from which all other classes are derived from it, or the hierarchy can have several basic classes whose function merges later in one or more derived class. Relations between classes can be illustrated as trees, and every smaller tree in great taxonomy can also be considered a hierarchy.

Not all class hierarchies can have more roots and structure of the class hierarchy in which it is written. Java®, on the other hand, is limited to one inheritance, so its class relations are usually simpler, built as relatively separate trees with a single root. Inheritance of the interface CPS some complexity of the class hierarchy in Java®, but the interface is almost never induced in such a complex framework that it would be like joining trees together.

Class hierarchy components may vary by type and function if the rules of language are always monitored with regard to inheritance. Classes in the hierarchy can be public, protected, abstract, specific or virtual. Interfaces, global functions and friends can also be used. Depending on the computer language, some of these types may better use the inheritance than others. In general, hierarchy is very flexible and can be used in many ways for many purposes.

There are no hard rules on where specific types of classes must be placed in the hierarchy. Any class can be any of the above types. In general, the last class in the hierarchy that has no derivation under them should be public and specific. However, since there may also be a purely abstract hierarchy of the class, but it is only a rule.

Although class hierarchy can be a useful tool for organizing code and encapsulationFunctionality, there may be times when immersion too deep into the hierarchy can actually confuse the code to clarify it and facilitate maintenance. Building a robust relationship between many classes requires a certain amount of anticipation; Although it would initially be easier to divide the code into many small pieces, these small pieces can later handle later. In the correct position of the class hierarchy, it helps developers and users to determine how classes work. If it is built without maintenance and clarity, many levels of inheritance can be confused and understood.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?