December 2003
Beginner
288 pages
7h 8m
English
Adding new features to a class might be as easy as extending an existing class, and adding a few new methods and modifying the behavior of others. It is not necessary to rewrite everything. This is where inheritance comes into play. If you have just written a Person class, you must consider the fact that you might later want to write an Employee class, or a Vendor class. Thus, having Employee inherit from Person might be the best strategy; in this case, the Person class is said to be extensible. You do not want to design Person so that it contains behavior that prevents it from being extended by classes such as Employee or Vendor (assuming, of course, that in your design you really intend for other classes ...
Read now
Unlock full access