Command Pattern
The command pattern encapsulates all of the information
needed to execute
an action. This is useful for operations that need to be invoked outside of the
context in which they were created. The Runnable
interface is an example
of the command pattern.
Observer Pattern
The observer pattern notifies a collection of observers about state changes
to a subject of interest. This is useful for decoupling
a subject from the concerns
of its followers. The Observer class and Observable interface are
examples of the observer pattern.
Strategy Pattern
The strategy pattern dynamically chooses
the behavior of an algorithm
at runtime. This is useful for operations that have a variety of custom
implementations. The Collections#sort(List, Comparator)
method is an example of the strategy pattern.
Visitor Pattern
The visitor pattern separates an algorithm from the
object structure on which
it operates. This is useful when different algorithms need to traverse a similar
path through a complex object. The ElementVisitor interface is an example
of the visitor pattern.
Null Object Pattern
The null object pattern represents an object with neutral or empty behavior.
This is useful to prevent excessive null checks in an application.
The Collections#emptyList() method is an example of the null
object pattern.