Friday, August 28, 2009

Patterns - 002: Basic java patterns


BASIC PATTERNS

In general, the functionality of an object-oriented system is encapsulated in the form of a set of objects. These objects provide different services either on their own or by interacting with other objects. In other words, a given object may rely upon the services offered by a different object to provide the service it is designed for. An object that requests a service from another object is referred as a client object. Some other objects in the system may seek the services offered by the client object.



Pattern NameDescription
InterfaceCan be used to design a set of service provider classes
that offer the same service so that a client object can
use different classes of service provider objects in a
seamless manner without having to alter the client
implementation.
Abstract Parent ClassUseful for designing a framework for the consistent
implementation of the functionality common to a set of
related classes.
Private MethodsProvide a way of designing a class behavior so that
external objects are not permitted to access the
behavior that is meant only for the internal use.
Accessor MethodsProvide a way of accessing an object’s state using specific
methods. This approach discourages different client
objects from directly accessing the attributes of an
object, resulting in a more maintainable class structure.
Constant Data ManagerUseful for designing an easy to maintain, centralized
repository for the constant data in an application.
Immutable ObjectUsed to ensure that the state of an object cannot be
changed. May be used to ensure that the concurrent
access to a data object by several client objects does not
result in race conditions.
MonitorA way of designing an application object so that it does
not produce unpredictable results when more than one
thread tries to access the object at the same time in a
multithreaded environment.

No comments:

Post a Comment