Java Design Patterns
Hang Song
Introduction
•
In fact, you probably don't write any code until
you can build a picture in your mind of what
code does and how the pieces of the code
interact.
•
The more elegant solution will be more reusable
and more maintainable. (even you are the only
programmer)
–
Good, simple, and reusable solutions.
–
To catalog common interactions between objects that
programmers have often found useful.
MVC
What is design pattern?
•
A design pattern describes how objects
communicate without becoming entangled in
each other's data models and methods.
•
Design Patterns—Elements of Reusable
Software, by Gamma, Helm, Johnson, and
Vlissides [1995]. This book, commonly called the
Gang of Four, or GoF, book, became an all-time
bestseller and has had a powerful impact on
those seeking to understand how to use design
patterns.
–
23 common, generally useful patterns and comments
on how and when you might apply them.
Defining Design Patterns
•
"Design patterns are recurring solutions to design
problems you see over and over.“
•
"Design patterns constitute a set of rules describing how
to accomplish certain tasks in the realm of software
development."
•
"Design patterns focus more on reuse of recurring
architectural design themes, while frameworks focus on
detailed design... and implementation."
•
"A pattern addresses a recurring design problem that
arises in specific design situations and presents a
solution to it."
•
"Patterns identify and specify abstractions that are above
the level of single classes and instances, or of
components."