I use the technique of finalising execute (1.1 equivelent of perform) and
having it do the lions share of the work for things. For example in a crud
action most of the work is occuring in execute and the subclasses just do
those things that are specific to the record type in question...

I find it works *very* well, and indeed I would suggest that for all but the
most trivial apps your wasting a lot of your own time by having any concrete
action class do ALL the work when you could be using inheritance and an
abstract superclass 'template' to take care of the generic stuff.

(Incidentally one thing Ive found useful when doing things this way is to
have the superclass execute method create
an 'ActionContext' bean that encapsulates the four parameters that get
passed to execute, and then you pass that to your subclasses. Saves a lot of
time, and gives you a spot you can add extra stuff to later instead of
having to change lots of method signatures.)


In terms of exception handling though, you may be better off using the
struts ExceptionHandler feature for dealing with exceptions thrown by
actions.

-----Original Message-----
From: Vijay K Hegde [mailto:[EMAIL PROTECTED]
Sent: Thursday, 18 September 2003 17:32
To: Struts Users Mailing List
Subject: Template Method Design


Hi,

  I have a requirement. Anybody has created an abstract action class that
extends Action. It makes the perform method as final. And creates an
abstract method satPerform that has to implemented by the classes extending
thus providing sort of a base class.

The intention behind is to take care of exception handling in the abstract
class and rest in the child classes.

Action ---->  perform()
Abstract Class extends Action----> final perform(), abstract satPerform()
SatAction extends Abstract -----> satPerform().

The pattern is Template Method Design.

If anybody has used such approach, please share the details.

If somebody could shed some light in this topic i would be grateful.

Vijay K. Hegde
Software Engineer
Infosys Technologies Limited, Hyderabad
* (040) 2300 5222 extn 23239



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to