There are often some helper components that are likely to be used all
across an app. Examples are:

   * a generalized error handler, e.g. to handle onFailure() from RPC
calls,

   * a generalized message display mechanism that can present messages
to the user in a generalized way, e.g. in a popup panel or in a DIV
dedicated to that purpose.

There are two designs of such components that I think both have some
advantages. Which design would you consider best practice?

1) Reach the component methods by firing events. Example:
   Error handler:
     eventBus.fireEvent(new Error(myException))
   Message displayer:
     eventBus.fireEvent(new Message("This is a message"))

   Pros: Seems very decoupled. The components them self can reach the
app (by firing new events). We can have multiple instances (even that
I can't see what multiple instances would be used for).
   Cons: Somewhat verbose syntax. Uses the eventBus (is this a con at
all?)

2) Reach the component methods as static methods. Example:
   Error handler:
       MyErrorHandler.handleError(myException)
   Message displayer:
       MessageDisplayer.display("This is a message")

   Pros: Simple syntax. Can use immediately, no need for making any
instances.
   Cons: The components them self cannot reach the app (e.g. by firing
new events). Cannot have multiple instances.

Which approach would you choose, and why?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to