Java Reference
In-Depth Information
This topic focuses on the most common Java EE design patterns and demonstrates how they are
implemented in the Java EE universe. Each chapter introduces a different pattern by explaining its
purpose and discussing its use. Then it demonstrates how the pattern is implemented in Java SE and
gives a detailed description of how it works. From there, the topic demonstrates how the pattern is
now implemented in Java EE and discusses its most common usage, its benei ts, and its pitfalls. All
explanations are accompanied by detailed code examples, all of which can be downloaded from
the website accompanying this topic. At the end of each chapter, you'll i nd a i nal discussion and
summary that rounds up all you have read in the chapter. There are even some interesting and some-
times challenging exercises for you to do that will test your understanding of the patterns covered in
the chapter.
WHAT IS A DESIGN PATTERN?
Design patterns are “descriptions of communicating objects and classes that are
customized to solve a general design problem in a particular context.”
—Gang of Four
Design patterns offer solutions to common application design problems. In object‐oriented pro-
gramming, design patterns are normally targeted at solving the problems associated with object
creation and interaction, rather than the large‐scale problems faced by the overall software architec-
ture. They provide generalized solutions in the form of boilerplates that can be applied to real‐life
problems.
Usually design patterns are visualized using a class diagram, showing the behaviors and relations
between classes. A typical class diagram looks like Figure 1-1.
Figure 1-1 shows the inheritance relationship between three classes. The subclasses
CheckingAccount and SavingsAccount inherit from their abstract parent class BankAccount .
BankAccount
owner : String
balance : Dollars
deposit (amount : Dollars)
withdrawal (amount : Dollars)
CheckingAccount
SavingsAccount
insuficientFundsFee : Dollars
processCheck (checkToProcess : Check)
withdrawal (amount : Dollars)
annualInterestRate : Percentage
depositMonthlyInterest()
withdrawal (amount : Dollars)
FIGURE 1-1: A class diagram showing inheritance
 
Search WWH ::




Custom Search