#17 Think about ChainOfResponsibility


Entvironment and Tools use ChainOfResponsibility in a
quite generic way. This is hard to understand and error

Is the genericity really neccessary? Isn't it much more
elegant to define some interfaces for the required

Example: now RequestHandler is an interface with the
method e handle(Request). The Interface is implemented
by the environment and all tools. In the environment
there is a type check to find out the concrete request
type. Then three requests are handled: create tool,
close tool and store material. With the
Chain-Of-Responsibility there is the chance for tools
to catch the request before it comes to the environment
and handle is themselve. But what is that good for? In
most cases catching up the requests will end up in hard
to understand errors.

Alternative 1: Create methods startTool, closeTool and
storeMaterial at Environment or ToolManager and let
these call from the abstract tool implementations in
JWAMToolConstruction direcly.

Alternative 2: If the chaining is still needed, create
an interface for each request type like
CreateToolHandler, CloseToolHandler and
StoreMaterialHandler. Provide specific handle...
methods in the interfaces. Let environment and tool
implement these interfaces.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks