Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 958462

Pages: 1
Jeff Varszegi
Unregistered




CoR is admittedly nice in some ways
      #1798 - 09/11/03 06:08 PM

The only thing I don't like about it is performance. The same old thread drives the process of letting each handler in the chain examine the object. That's why a naive implementation of CoR is only a decent solution when you're sure that the number of handlers is guaranteed to be relatively small.

In a multi-threaded situation, though, where each handler can examine the object on its own time (and perhaps simultaneously), letting the handler decide whether to handle the request works just fine. This is part of the beauty of JavaSpaces.

You can also implement a multithreaded lookup processor, where each lookup thread examines a group of potential handlers until one is found, to good effect in certain situations.

In actual practice, I've found that it's better to let an external controller check each item in the "chain" for its ability to handle the request, and if not, check the next. This lets you dispense with the chain/list itself, instead treating the items as an array. This is good because you always have to be able to interrupt the sequence (like in case of interrupt or shutdown requests being received by the application). To build the interrupting logic into a chain class (like FilterChain) makes it less of a clean implementation, and there's no problem with letting the controller handle this.

Jeff
jvarszegi@hotmail.com


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: CoR is admittedly nice in some ways [Re: Jeff Varszegi]
      #21312 - 08/25/05 03:26 AM

Quote:

The only thing I don't like about it is performance. The same old thread drives the process of letting each handler in the chain examine the object. That's why a naive implementation of CoR is only a decent solution when you're sure that the number of handlers is guaranteed to be relatively small.

In a multi-threaded situation, though, where each handler can examine the object on its own time (and perhaps simultaneously), letting the handler decide whether to handle the request works just fine. This is part of the beauty of JavaSpaces.

You can also implement a multithreaded lookup processor, where each lookup thread examines a group of potential handlers until one is found, to good effect in certain situations.

In actual practice, I've found that it's better to let an external controller check each item in the "chain" for its ability to handle the request, and if not, check the next. This lets you dispense with the chain/list itself, instead treating the items as an array. This is good because you always have to be able to interrupt the sequence (like in case of interrupt or shutdown requests being received by the application). To build the interrupting logic into a chain class (like FilterChain) makes it less of a clean implementation, and there's no problem with letting the controller handle this.

Jeff
jvarszegi@hotmail.com


I appreciate the way Jeff looks towards CoR, I also appreiate the way he suggests for converting the cons to pros. ----Gautam

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: CoR is admittedly nice in some ways [Re: Jeff Varszegi]
      #29657 - 03/14/06 10:27 AM

Wouldn't the use of a controller negate the effects of CoR? Now it's coupled to all possible handlers so even though the client is not tightly couped, the controller object is. Sounds like it just shifts the problem instead of solving it...

Dima
zemsk55c@erau.edu


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 8750

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5