Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@apache.org Received: (qmail 7181 invoked from network); 13 Sep 2002 15:01:08 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 13 Sep 2002 15:01:08 -0000 Received: (qmail 17246 invoked by uid 97); 13 Sep 2002 15:01:20 -0000 Delivered-To: qmlist-jakarta-archive-struts-user@jakarta.apache.org Received: (qmail 17190 invoked by uid 97); 13 Sep 2002 15:01:19 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 17168 invoked by uid 98); 13 Sep 2002 15:01:18 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) X-Originating-IP: [32.97.110.142] From: "David Graham" To: struts-user@jakarta.apache.org Bcc: Subject: Re: [FormBean] Question concerning memory / casting Date: Fri, 13 Sep 2002 09:00:40 -0600 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 13 Sep 2002 15:00:41.0910 (UTC) FILETIME=[5437CD60:01C25B36] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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" >Reply-To: "Struts Users Mailing List" >To: Struts Users Mailing List >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 > > Reply-To: Struts Users Mailing List > > To: Struts Users Mailing List > > 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" > > To: "Struts Users Mailing List" > > 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: > > > > > > For additional commands, e-mail: > > > > > > > > > > > > -- > > > To unsubscribe, e-mail: > > > > > For additional commands, e-mail: > > > > > > > > > > > -- > > To unsubscribe, e-mail: > > > For additional commands, e-mail: > > > > > > > >-- >To unsubscribe, e-mail: > >For additional commands, e-mail: > _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- To unsubscribe, e-mail: For additional commands, e-mail: