Java Reference
In-Depth Information
Part II: Patterns in the Java Programming Language
Chapter 5. Introduction to Java Programming Language Patterns
In the first part of this topic, a common set of patterns is discussed. The patterns are listed with descriptions of
their characteristics, the benefits and drawbacks associated with them, examples of their use and code samples
demonstrating the patterns in action.
The basic patterns discussed are platform and language-neutral. While it's true that Java is especially well-suited
to some of these patterns, they can be implemented in languages that support the core object-oriented properties
of inheritance, encapsulation, polymorphism, and abstract classes.
Now it's time to shift gears and look at pattern use in the Java APIs. Since the Java programming language and
the Design Patterns movement grew up together, the developers used a number of design patterns when they
created the Java APIs. The goal is to gain an understanding of how Java is put together, and to answer questions
like:
How does Java as a language make use of patterns?
How does it use patterns to make its APIs more effective?
The Java APIs provide additional demonstrations of pattern use. Like the Personal Information Manager
examples in Part I , these real-world patterns provide useful insight into how patterns can be effectively applied to
solve problems.
At this point, it's worth explaining what exactly is meant by “API.” It's become a somewhat vague term in recent
years. These days, API is used to refer to a single class, a group of classes, a single package or a set or related
packages. The important quality that defines an API is the fact that it provides a programming framework for a set
of related functional capabilities.
A number of the APIs in the following chapters are actually designed as a set of related classes. To appreciate the
way that an API functions as a whole, it makes sense to spend some time discussing its basic structure. This
provides a perspective on how patterns support the API - how they help a specific API to better do its job. This
means that this section of the topic is effectively part architectural evaluation, part pattern study. This provides a
few practical benefits:
It can help you appreciate some of the ways that patterns are actually used within the API. Studying the Java APIs
demonstrates how patterns can be applied to achieve practical goals.
It shows how you can use patterns with the APIs. Examining a set of APIs can help you see how to effectively
use a pattern to interact with an API or framework.
In the pages that follow, you'll take a look at a number of Java APIs and see what makes them tick. This should
give you new insight into their use and usefulness - perhaps even on why they're designed the way they are. With
these thoughts in mind, let's begin our exploration.
Note
The APIs discussed in the following chapters are divided into several sections. First, the Packages section
describes which packages contain the classes and interfaces that make up the API. Next, the Overview section
provides a brief review of each API. The Overview section is not meant to teach an entire API. It is a reminder to
those who know the API, and a list of highlights for those of you who plan to learn more about it as you continue
to program. The final section is called Pattern Use; it presents design patterns used in the APIs, and describes how
they are used.
 
 
Search WWH ::




Custom Search