Template Method Design

2003-09-18 Thread Vijay K Hegde
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]



Re: Template Method Design

2003-09-18 Thread Pat Quinn
Take a look at Chapter 10 - Exception Handling in Programming Jakarta Struts 
by chuck cavaness.. i think you'll find this very helpful.

I've implement this with Action but ill soon need to do the same for 
Dispatch Action too... has anyone done likewise for Dispatch and other such 
actions?



From: Vijay K Hegde [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Subject: Template Method Design
Date: Thu, 18 Sep 2003 15:01:59 +0530
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]
_
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail

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


RE: Template Method Design

2003-09-18 Thread Andrew Hill
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]