Java Reference
In-Depth Information
C ALLER C LASS
Again, the consumer class using ErrorMsg does not change, even though you are
performing a new function
ErrorMsg myErrorMsg = new ErrorMsg ();
// Call the translate method in the subclass ErrorMsg.
String FrenchText = myErrorMsg.getTranslation ();
W HY I NHERITANCE ?
Inheritance is not a concept with a good COBOL equivalent, so you're probably ask-
ing, “What's the big deal here? Why would anyone want to do this?” The answer is
best explained in the context of design patterns, a theory that has become an im-
portant concept in OO circles. (This theory is described in Design Patterns: Elements
of Reusable Object-Oriented Software by Gamma, Helm, Johnson, and Vlissides, pub-
lished by Addison Wesley Professional in 1994.) The basic premise of design pattern
theory is that many development issues can be organized into related groups. If one
uses predefined and generally accepted approaches to solving the problems for that
group, developers will readily recognize the approach. As a result, the developer will
be guided toward the best implementation of a solution for that problem. The qual-
ity of the solutions built based on well understood approaches, or patterns, is im-
proved. Further, the time spent on developing the solution is reduced.
A fundamental design pattern is the idea of objects, or reusable blocks of code,
that perform a specific task. The theory is that application development problems
(or, more precisely, their solutions) are best addressed by breaking down the prob-
lem and implementing the most elegant, flexible solution possible. According to
object-oriented theory, a solution based on objects will be cheaper and easier to
maintain in the long run. An object-oriented analysis attempts to examine a prob-
lem using these criteria:
What is generic and what is specific about a particular solution? That is, how
can I represent my objects so that the characteristics shared by many objects are
isolated from those that are unique to my object?
How can I abstract my design so that the things likely to change are isolated
from those that are constant? Since maintenance and customization is the most
expensive part of any programming effort, it is important to concentrate the por-
tions with high activity in one place, separate from those with modest activity.
Search WWH ::




Custom Search