Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@apache.org Received: (qmail 91562 invoked from network); 9 Jul 2003 17:46:01 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 9 Jul 2003 17:46:01 -0000 Received: (qmail 27945 invoked by uid 97); 9 Jul 2003 17:48:30 -0000 Delivered-To: qmlist-jakarta-archive-struts-user@nagoya.betaversion.org Received: (qmail 27938 invoked from network); 9 Jul 2003 17:48:30 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 9 Jul 2003 17:48:30 -0000 Received: (qmail 89323 invoked by uid 500); 9 Jul 2003 17:45:34 -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 89298 invoked from network); 9 Jul 2003 17:45:34 -0000 Received: from hades.labone.com (HELO ?198.70.194.2?) (198.70.194.2) by daedalus.apache.org with SMTP; 9 Jul 2003 17:45:34 -0000 Received: from mailgate.labone.com by [198.70.194.2] via smtpd (for daedalus.apache.org [208.185.179.12]) with SMTP; 9 Jul 2003 17:45:51 UT Received: from 172.24.1.28 by mailgate.labone.com with ESMTP (SMTP Relay (MMS v4.7);); Wed, 09 Jul 2003 12:45:50 -0500 X-Server-Uuid: d2c6f521-be8f-45bd-b261-f27c182a9ace Received: by mail.1.24.172.in-addr.arpa with Internet Mail Service ( 5.5.2653.19) id ; Wed, 9 Jul 2003 12:45:50 -0500 Message-ID: <7851AE957357D611A8EB000347961E770E65A041@mail.1.24.172.in-addr.arpa> From: "Jerry Jalenak" To: "'Struts Users Mailing List'" Subject: RE: [OT] Use of Static Methods Date: Wed, 9 Jul 2003 12:45:50 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) X-WSS-ID: 13128B4432071-01-02 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Thanks to everyone for weighing in on this. I certainly didn't expect this type of discussion. Let me give an example of what we are trying to do, and see if this is appropriate or not. For various reasons we have a 'roll your own' logon authentication process. Part of the process takes the users password, and using a stored digest key, we encrypt it and then compare it to the stored (encrypted) password. If they match, great. If not, then we return an error. The code that we use to do the encryption looks like the following: public static byte[] getEncryptedPassword(byte[] digestKey, String password) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(digestKey); md.update(password.getBytes()); return (md.digest()); } catch(Exception e) { return (null); } } The class name is 'Password', so to call this method we use something like 'Password.getEncryptedPassword(storedDigestKey, enteredPassword)'. Is this type of method appropriate for a 'static' method? Or should this be a singleton? Or a normal class? Jerry Jalenak Team Lead, Web Publishing LabOne, Inc. 10101 Renner Blvd. Lenexa, KS 66219 (913) 577-1496 jerry.jalenak@labone.com -----Original Message----- From: Yee, Richard K,,DMDCWEST [mailto:Yeerk@osd.pentagon.mil] Sent: Wednesday, July 09, 2003 12:35 PM To: 'Struts Users Mailing List' Subject: RE: [OT] Use of Static Methods I and a lot of other developers would disagree with the statement "Static methods are evil for many reasons including philosophical (they're not OO) and practical (you can't override their behavior)." 1) Whenever you write a method that only accesses static data of a class, you should declare the method as static. 2) It is not correct to say that static methods can't be overriden. They can be overridden with another static method. You can't override a static method to be non-static, however. 3) There are many cases where using the static modifier on a method is totally appropriate. Typically, they are used on methods that provide a very specific functionality that will never change. Using the static modifier on such methods also reduces the overall memory footprint of an application. Regards, Richard -----Original Message----- From: David Graham [mailto:grahamdavid1980@yahoo.com] Sent: Wednesday, July 09, 2003 9:22 AM To: Struts Users Mailing List Subject: RE: [OT] Use of Static Methods > > One of my programmers asked me whether or not it is OK to define > helper methods as 'static' - and I realized that I didn't know the > answer. So I guess the question is, in a web application, can common > code be factored out > to a helper class and marked as 'static'? Static methods are evil for many reasons including philosophical (they're not OO) and practical (you can't override their behavior). You should use a Singleton class with non-static methods. Struts' RequestUtils class is a good example of why you should never use static methods. Developers want to override their behavior but can't because everything is static. David > Are there any major problems > with > doing this? I should know the answer, but just can't put my thumb on > it right now.... 8) > > TIA! > > Jerry Jalenak > Team Lead, Web Publishing > LabOne, Inc. > 10101 Renner Blvd. > Lenexa, KS 66219 > (913) 577-1496 > > jerry.jalenak@labone.com > > > This transmission (and any information attached to it) may be > confidential and is intended solely for the use of the individual or > entity to which it is > addressed. If you are not the intended recipient or the person > responsible for > delivering the transmission to the intended recipient, be advised that > you have > received this transmission in error and that any use, dissemination, > forwarding, > printing, or copying of this information is strictly prohibited. If you > have > received this transmission in error, please immediately notify LabOne at > the > following email address: securityincidentreporting@labone.com > > > > --------------------------------------------------------------------- > 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 > __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com --------------------------------------------------------------------- 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 This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at the following email address: securityincidentreporting@labone.com --------------------------------------------------------------------- To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: struts-user-help@jakarta.apache.org