Magazine
 

Design Pattern

 
Behavioral Patterns Behavioral patterns are those patterns, which are specifically concerned with communication (interaction) between the objects. The interactions between the objects should be such that they are talking to each other and are still loosely coupled. The loose coupling is the key to n-tier architectures. In this, the implementations and the client should be loosely coupled in order to avoid hard coding and dependencies. The behavioral patterns are:

1. Chain of Responsibility Pattern
2. Command Pattern
3. Interpreter Pattern
4. Iterator Pattern
5. Mediator Pattern
6. Momento Pattern
7. Observer Pattern
8. State Pattern
9. Strategy Pattern
10. Template Pattern
11. Visitor Pattern

Some of the important and useful pattern which are frequently used in java are as under: Chain of Responsibility pattern: As per concern the Object Oriented Design, it is a design pattern based on chain that consists a source of command objects and a series of processing objects. In this pattern, each processing object holds a set of logic, which describes the kinds of command objects. These Objects are in the form of a chain that forwards the request until one of the objects handles the event. In other words, this pattern decouples the sender who sends the requested data. The receiver or any members of the “chain” pick that data. If the first link of the chain cannot handle the responsibility, it passes the request data to the next level in the chain, i.e. to the next link until one of the objects handles the event. This is similar to concepts Exception Hierarchy in Java. This technique is called “data-driven”. In most of the behavioral patterns, the data-driven concepts are used to have a loose coupling.
  including a new processing object to the end of this chain.

The Chain of Responsibility pattern is applicable if:

1. We want to decouple a request’s sender and receiver. 2. We don’t want to assign handlers explicitly in our code. 3. Multiple objects are nominees to handle a request at runtime.

There are some key points to remember when we use the Chain of responsibility pattern like only one object in the chain handles a request. There are also some possibilities for some requests might not get handled.

“Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.”




A typical object structure of chain of responsibility is shown as:


Dec 2007 | Java Jazz Up | 65
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 ,

Download PDF