|
Interfaces, GUIs, and Applets
|
CS 161 - Java |
A mousetrap, student, roster, bank account, professor, ____________
should contain just what is needed to accomplish the problem task and
support the required interface.
Implementation details should not be accessible outside of an
object: objects should only expose public
ly the methods
and fields they are willing to maintain.
An object type that inherits from another can provide additional
details (specialization) as well as extended capabilities provided
by the more generic parent (super
) class.
Creating abstract
and generic classes and then sub
classes that inherit from them can be useful, but ...
-
When you are just starting, don't get hung up on creating an elaborate
inheritance hierarchy.
-
Concentrate on your immediate problem, use inheritance only
if it helps you achieve your ultimate goal.
-
You might do better to think of designing in terms of
interfaces
if you want to maximize re-usability.