Chapter 21
Factoring Classes
In This Chapter
Factoring common properties into a base class
Using abstract classes to hold factored information
Declaring abstract classes
Inheriting from an abstract class
Dividing a program into multiple modules using a project file
The concept of inheritance allows one class to inherit the properties of a base class. Inheritance has a number of purposes, including paying for my son’s college. The main benefit of inheritance is the ability to point out the relationship between classes. This is the so-called IS_A relationship — a MicrowaveOven IS_A Oven and stuff like that.
Factoring is great stuff if you make the correct correlations. For example, the microwave versus conventional oven relationship seems natural. Claim that microwave is a special kind of toaster, and you’re headed for trouble. True, they both make things hot, they both use electricity, and they’re both found in the kitchen, but the similarity ends there — a microwave can’t make toast ...
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