Generalization, Specialization, and Inheritance - The Process - The Generalization Process

3 important questions on Generalization, Specialization, and Inheritance - The Process - The Generalization Process

When you have several classes with similar attributes and similar behaviors, you can look for....?

When you have several classes with similar attributes and similar behaviors, you can look for common features
Report

Consider that a jurisdiction may have licensing procedures for dogs, cats, tigers, snakes, and alligators.

Instead of treating them all separately, you could also...?

Instead of treating them all separately, if you abstract the common features from each class and create a new superclass to house these common features, you could define many of the features only once.

You could create a Pet class—Allowing a loop through all the pets during renewal season without making separate loops for each subclass.
Report

If the details of getting or renewing a license were different for each subclass, you would define an abstract operation on the Pet class called renewLicense().

What would each subclass have then?

Each subclass would have to have the specific implementation for the operation.

However, the users of the Pet class would not have to deal with the details and would not need to know what type of Pet is currently being handled.
Report

The question on the page originate from the summary of the following study material:

  • A unique study and practice tool
  • Never study anything twice again
  • Get the grades you hope for
  • 100% sure, 100% understanding
Remember faster, study better. Scientifically proven.
Trustpilot Logo
  • Higher grades + faster learning
  • Never study anything twice
  • 100% sure, 100% understanding
Discover Study Smart