struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Graham" <dgraham1...@hotmail.com>
Subject Re: [FormBean] Question concerning memory / casting
Date Fri, 13 Sep 2002 15:00:40 GMT
Style 2 is disgusting.  I don't trust the compiler to make up for poor 
programming style so I would go with style 1.  The performance difference 
probably won't matter but reading and maintaining 2 would be difficult.  The 
thought of typing out all those casts make me cringe :-).

Dave


>From: "Craig R. McClanahan" <craigmcc@apache.org>
>Reply-To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
>To: Struts Users Mailing List <struts-user@jakarta.apache.org>
>Subject: Re: [FormBean] Question concerning memory / casting
>Date: Fri, 13 Sep 2002 06:55:56 -0700 (PDT)
>
>
>
>On Fri, 13 Sep 2002, Michael Delamere wrote:
>
> > Date: Fri, 13 Sep 2002 13:12:07 +0200
> > From: Michael Delamere <home@michael-delamere.de>
> > Reply-To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> > To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> > Subject: Re: [FormBean] Question concerning memory / casting
> >
> > oops, of course I did :-)
> >
> > so what I mean was:
> >
> >  1)
> >  ProductFB prodFB = (ProductFB)form;
> >  prodFB.getName();
> >  prodFB.getDescription();
> >  prodFB.getPrice();
> >  prodFB.getPackaging();
> >  prodFB.getAttributes();
> >
> >  2)
> > ((ProductFB)form).getName();
> > ((ProductFB)form).getDescription();
> > ((ProductFB)form).getPrice();
> > ((ProductFB)form).getPackaging();
> > ((ProductFB)form).getAttributes();
> >
>
>The potential performance difference is if the cast is performed more than
>once during style (2).  With a good optimizing compiler, that should
>not be the case -- the compiler should be able to recognize and reuse the
>results of the first cast for all of them, and the performance would
>essentially be identical.
>
>As to whether any given compiler is good at this, I don't know -- it might
>be interesting to write a real short test case, and dump out the bytecodes
>that are produced with some analysis tool to figure it out for your
>compiler.
>
>Personally, I use style (1) -- but that's more because its fewer
>keystrokes than for any performance oriented reason.  I don't worry about
>optimizations at this kind of detailed level until (a) experience shows I
>have a performance issue in the app, and (b) tools like OptimizeIt
>identify the method containing these things as a hot spot.
>
> > Thanks!
>
>Craig
>
>
> >
> > ----- Original Message -----
> > From: "Andrew Hill" <andrew.david.hill@gridnode.com>
> > To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
> > Sent: Friday, September 13, 2002 12:52 PM
> > Subject: RE: [FormBean] Question concerning memory / casting
> >
> >
> > > Ummm. In (1) did you mean to say ProductFB prodFB = (ProductFB)form;
> > > ???
> > >
> > > If you did then I would have thought the second more runtime efficient 
>(I
> > > could well be wrong of course. Will be intersting to see what others 
>say),
> > > though I prefer the first as its easier to read, maintain, and write 
>:-)
> > >
> > > -----Original Message-----
> > > From: Michael Delamere [mailto:home@michael-delamere.de]
> > > Sent: Friday, September 13, 2002 19:00
> > > To: Struts Users Mailing List
> > > Subject: [FormBean] Question concerning memory / casting
> > >
> > >
> > > Hi,
> > >
> > > Iīve noticed that some of the developers here (in my company) are
> > > programming in a style where Iīm not sure if its clean or maybe even 
>not
> > > very good in performance.  I would like to address this issue, but as 
>you
> > > know, itīs a bit impossible if you yourself do not know any better!
> > >
> > > Please donīt flame because of the fact that this isnīt 100% a struts
> > > specific question!
> > >
> > > Scenario:
> > >
> > > The are two ways of retrieving data out of my form bean:
> > >
> > > 1)
> > > ProductFB prodFB = new ProductFB();
> > > prodFB.getName();
> > > prodFB.getDescription();
> > > prodFB.getPrice();
> > > prodFB.getPackaging();
> > > prodFB.getAttributes();
> > >
> > > 2)
> > > ((ProductFB)form).getName();
> > > ((ProductFB)form).getDescription();
> > > ((ProductFB)form).getPrice();
> > > ((ProductFB)form).getPackaging();
> > > ((ProductFB)form).getAttributes();
> > >
> > >
> > > The latter is the one that I have seen being used in various classes 
>now.
> > I
> > > personally donīt like this one and wanted to know if there are 
>possibly
> > any
> > > other implication like memory or casting issues.
> > >
> > > Youīre help would be VERY appreciated!
> > >
> > > Thanks,
> > >
> > > Michael
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <mailto:struts-user-help@jakarta.apache.org>
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <mailto:struts-user-help@jakarta.apache.org>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:   
><mailto:struts-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: 
><mailto:struts-user-help@jakarta.apache.org>
> >
> >
>
>
>--
>To unsubscribe, e-mail:   
><mailto:struts-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: 
><mailto:struts-user-help@jakarta.apache.org>




_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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


Mime
View raw message