You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Felipe Nascimento <fe...@inf.puc-rio.br> on 2003/12/07 04:15:28 UTC

from Action to Facade: simple attributes or Business Objects

Hi,

I was wondering what do experts recommend:

inside Action´s execute method we should pass the attributes to the Facade
or create the business objects in the Action and pass them on?

1)
execute(....){
     Facade.addUser(name, surname, login, birth, ....);
}

or

2)
execute(....){
     User u = new User();
     u.setName(name);
     u.setSurname(surname);
     ......others setters.
     Facade.addUser(u);
}

Tks
Felipe



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RES: from Action to Facade: simple attributes or Business Objects

Posted by Felipe Nascimento <fe...@inf.puc-rio.br>.
Tks for the reply Tim.

I now see the advantages of my latter case.
But being my form bean a DynaActionForm, can I still use
BeanUtils.populate()??
If not, what would be the alternative?

Tks
Felipe

-----Mensagem original-----
De: Tim Lucia [mailto:timlucia@yahoo.com] 
Enviada em: domingo, 7 de dezembro de 2003 10:54
Para: 'Struts Users Mailing List'
Assunto: RE: from Action to Facade: simple attributes or Business
Objects


The philosphy is that the Actions ("controller") move bean properties
from form bean(s) into business beans, and pass the business bean into a
business object to perform an operation.  I.e., the action should
contain all of (and only) the web-specific portion of the application.
I.e., the latter case in your example.  Think about what happens if you
add a property?  How many places do you need to change it?  One less (at
least) in the patter case.  You can (typically) use BeanUtils.populate()
do move all properties in one fell swoop.

Tim Lucia


> -----Original Message-----
> From: Felipe Nascimento [mailto:felipenasc@inf.puc-rio.br]
> Sent: Saturday, December 06, 2003 10:15 PM
> To: struts-user@jakarta.apache.org
> Subject: from Action to Facade: simple attributes or Business Objects
> 
> 
> Hi,
> 
> I was wondering what do experts recommend:
> 
> inside Action´s execute method we should pass the attributes
> to the Facade or create the business objects in the Action 
> and pass them on?
> 
> 1)
> execute(....){
>      Facade.addUser(name, surname, login, birth, ....);
> }
> 
> or
> 
> 2)
> execute(....){
>      User u = new User();
>      u.setName(name);
>      u.setSurname(surname);
>      ......others setters.
>      Facade.addUser(u);
> }
> 
> Tks
> Felipe
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.547 / Virus Database: 340 - Release Date: 2/12/2003
 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: from Action to Facade: simple attributes or Business Objects

Posted by Tim Lucia <ti...@yahoo.com>.
The philosphy is that the Actions ("controller") move bean properties
from form bean(s) into business beans, and pass the business bean into a
business object to perform an operation.  I.e., the action should
contain all of (and only) the web-specific portion of the application.
I.e., the latter case in your example.  Think about what happens if you
add a property?  How many places do you need to change it?  One less (at
least) in the patter case.  You can (typically) use BeanUtils.populate()
do move all properties in one fell swoop.

Tim Lucia


> -----Original Message-----
> From: Felipe Nascimento [mailto:felipenasc@inf.puc-rio.br] 
> Sent: Saturday, December 06, 2003 10:15 PM
> To: struts-user@jakarta.apache.org
> Subject: from Action to Facade: simple attributes or Business Objects
> 
> 
> Hi,
> 
> I was wondering what do experts recommend:
> 
> inside Action´s execute method we should pass the attributes 
> to the Facade or create the business objects in the Action 
> and pass them on?
> 
> 1)
> execute(....){
>      Facade.addUser(name, surname, login, birth, ....);
> }
> 
> or
> 
> 2)
> execute(....){
>      User u = new User();
>      u.setName(name);
>      u.setSurname(surname);
>      ......others setters.
>      Facade.addUser(u);
> }
> 
> Tks
> Felipe
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org