answersLogoWhite

0

In the real world, we humans like to classify everything from living things to inanimate objects, grouping things by the properties they share. For instance, in the world of living things we classify everything by kingdom, phylum, class, infraclass, order, suborder, family, subfamily, tribe, subtribe, genus and species. Thus the homo sapiens species belongs to the kingdom of animals, the phylum of chordata, the class of mammals, the order of primates, the family of hominidae, the tribe of hominini and the genus homo. Each classification is a more specialised type than the one that precedes it. Thus higher classes are more generic and lower classes more specific. The bat, which is also in the class of mammals, shares the same phylum and kingdom as we do, but differs in its order, family, tribe and genus. Thus we are related to bats in as much as we are both a type of mammal.

This type of classification is known as a taxonomy, and can be represented as a hierarchy, a family tree structure, with the most generic class at the top, or root, and the more specialised types splitting off on each subsequent level.

Just as we classify objects in the real world, we classify objects in the virtual world using a virtual taxonomy. The virtual taxonomy need not accurately reflect any real world taxonomy of the objects we are representing. If we wished to model a dog kennel, then we can limit the taxonomy to the genus: canis. If we also wished to identify the individual species and breed of dog then we might include those more specialised classifications, or we may limit our classification to breed. The point is we need only include those aspects that are actually of relevance to our program. For instance, we don't really need to know that a dog is actually a class of mammal unless we wished to segregate mammals from other classes, such as reptiles, but group them as animals.

By organising objects in this manner, we can greatly reduce the amount of duplicate code we need to write simply by encapsulating the generic functionality within the upper base classes, and placing the more specific functionality within the lower derived classes. For instance, most animals make some sort of noise, thus every animal object can "speak". When we call that method upon a dog, we would expect it to bark, while a cat should meow. These are simply specialised methods of a common, generic method. Animals that don't make a noise can simply default to the generic animal method, which simply produces no sound. Thus we need only cater for those that do make a sound.

User Avatar

Wiki User

11y ago

Still curious? Ask our experts.

Chat with our AI personalities

ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
ProfessorProfessor
I will give you the most educated answer.
Chat with Professor
CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach

Add your answer:

Earn +20 pts
Q: Real world is full of classes explain?
Write your answer...
Submit
Still have questions?
magnify glass
imp