On Sun, 25 Nov 2001, box wrote:

> Date: Sun, 25 Nov 2001 22:53:38 +0100
> From: box <[EMAIL PROTECTED]>
> Reply-To: Struts Developers List <[EMAIL PROTECTED]>,
>      box <[EMAIL PROTECTED]>
> To: Struts Developers List <[EMAIL PROTECTED]>
> Subject: Re: General model question ?
>
> Thank you Craig,
>
> I see the point, You are right it makes a lot of sense. But the behind the
> scene matter of my question was the performance reason.
> I have to copy all the properties of ActionForm to appropriate business
> logic object. The clean way of doing this is using the reflection API, which
> is rather slow.
>


First, you're going to have to do this type of conversion anyway --
because HTTP parameters come in as strings, you don't want to directly use
things like java.util.Date for the properties.

Second, have you *yourself* done benchmarks that the "cost" of reflection
even matters?  Consider:

* This is totally an issue of CPU time - economically, this is an
  incredibly easy problem to solve (in fact, it's very difficult to
  buy a new processor that is faster than your current one, but actually
  costs you more money).

* Modern JVMs have ***vastly*** narrowed the performance gap between
  reflection based calls and direct calls.  In the very large majority
  of cases, it's just not worth worrying about.

* If our application is based on EJBs, it is already doing a *lot* more
  reflection-based processing than Struts is doing.

My advice would be focus on reducing developer effort -- this is
***much*** more expensive than whatever hardware you utimately deploy your
application on.

> regards Wojtek
>

Craig


> ----- Original Message -----
> From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
> To: "Struts Developers List" <[EMAIL PROTECTED]>; "box"
> <[EMAIL PROTECTED]>
> Sent: Sunday, November 25, 2001 7:14 AM
> Subject: Re: General model question ?
>
>
> >
> >
> > On Thu, 22 Nov 2001, box wrote:
> >
> > > Date: Thu, 22 Nov 2001 19:36:25 +0100
> > > From: box <[EMAIL PROTECTED]>
> > > Reply-To: Struts Developers List <[EMAIL PROTECTED]>,
> > >      box <[EMAIL PROTECTED]>
> > > To: [EMAIL PROTECTED]
> > > Subject: General model question ?
> > >
> > > Hi everybody,
> > >
> > >  I am new to struts, but I find them very usefull.
> > >
> > >  There is one question that bothers me.
> > >
> > >  Wy is ActionForm a class not an interface ?
> > >
> > >  I have got my own application data model and I would just need  to
> > > implement
> > >  the ActionForm to update/input the data via html forms.
> > >
> > >  But it's not possible - I must inherit the struts structure, so I have
> to
> > >  create ActionForm with get, set methods and after all copy all
> properties
> > >  between my data model and the corresponding ActionForm.
> > >
> > >  Am I missing something ?
> > >
> >
> > ActionForm is a class in order to *prevent* exactly the behavior you
> > propose :-).
> >
> > The purpose of an ActionForm is to contain the server-side state of the
> > input fields, for the following reasons:
> >
> > * So that you can validate them (you don't want invalid data
> >   being scribbled into your application data objects by Struts's
> >   automatic bean population)
> >
> > * So that you can reproduce the user's input data in case of an
> >   error such as an invalid integer (you would use a String in the
> >   ActionForm for an EJB property that is an "int").
> >
> > * So that your application data objects can be reused in non-Struts
> >   contexts (otherwise, they would always require struts.jar to be around).
> >
> > You *really* don't want to modify anything in your application data model
> > until *after* validation has succeeded.  That's why the Struts design
> > pattern is to do this in an Action, by copying the appropriate values from
> > the ActionForm into your application data objects, performing any data
> > conversions that are necessary.  Making ActionForm a class instead of an
> > interface forces you to do the right thing.
> >
> > >  regards
> > >
> > >  Wojtek
> > >
> >
> > Craig McClanahan
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
> > --
> > Myslisz o otworzeniu wlasnego sklepu internetowego?
> > A moze o wynajeciu stoiska w wirtualnym pasazu?
> > W Centrum e-biznesu mozesz miec jedno i drugie. Juz od 290 zl za rok.
> > Wybierz: e-witryne lub e-sklep. http://handel.getin.pl/
> >
> >
>
>
> --
> Myslisz o otworzeniu wlasnego sklepu internetowego?
> A moze o wynajeciu stoiska w wirtualnym pasazu?
> W Centrum e-biznesu mozesz miec jedno i drugie. Juz od 290 zl za rok.
> Wybierz: e-witryne lub e-sklep. http://handel.getin.pl/
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


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

Reply via email to