commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Graham" <dgraham1...@hotmail.com>
Subject Re: cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator CreditCardValidator.java GenericValidator.java
Date Wed, 30 Apr 2003 21:31:26 GMT
Rob,
I absolutely hate static methods for the sole reason that they prevent 
polymorphism/overriding.  IMHO, static methods are a crutch far too heavily 
relied on in OO languages (one good use case is retrieving a Singleton).  I 
can't think of a reason to override these particular methods' behavior but 
the framework should allow it.

So, unless I've missed some important reason for making methods static 
please change them back to instance methods.

Thanks,
David



>From: rleland@apache.org
>Reply-To: "Jakarta Commons Developers List" 
><commons-dev@jakarta.apache.org>
>To: jakarta-commons-cvs@apache.org
>Subject: cvs commit: 
>jakarta-commons/validator/src/share/org/apache/commons/validator 
>CreditCardValidator.java GenericValidator.java
>Date: 30 Apr 2003 21:24:41 -0000
>
>rleland     2003/04/30 14:24:41
>
>   Modified:    validator/src/share/org/apache/commons/validator
>                         CreditCardValidator.java GenericValidator.java
>   Log:
>   Methods could be static in CreditCard Validation,
>   and so they were made static, since I couldn't think
>   of any use cases that would require setting options
>   for to change validation behavour.
>
>   Revision  Changes    Path
>   1.2       +8 -8      
>jakarta-commons/validator/src/share/org/apache/commons/validator/CreditCardValidator.java
>
>   Index: CreditCardValidator.java
>   ===================================================================
>   RCS file: 
>/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/CreditCardValidator.java,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- CreditCardValidator.java	29 Apr 2003 01:45:43 -0000	1.1
>   +++ CreditCardValidator.java	30 Apr 2003 21:24:41 -0000	1.2
>   @@ -66,9 +66,9 @@
>     * <p>
>     * This class is a Singleton; you can retrieve the instance via the 
>getInstance() method.
>     * </p>
>   - * Reference Sean M. Burke's script at
>   + * Reference Sean M. Burke's script at
>     * http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl
>   - *
>   + *
>     * @author David Winterfeldt
>     * @author James Turner
>     * @author <a href="mailto:husted@apache.org">Ted Husted</a>
>   @@ -118,7 +118,7 @@
>    	 *
>    	 * @param cardNumber Credit Card Number.
>    	 */
>   -	protected boolean validateCreditCardLuhnCheck(String cardNumber) {
>   +	protected static boolean validateCreditCardLuhnCheck(String 
>cardNumber) {
>    		// number must be validated as 0..9 numeric first!!
>    		int digits = cardNumber.length();
>    		int oddoeven = digits & 1;
>   @@ -155,7 +155,7 @@
>    	 *
>    	 * @param cardNumber Credit Card Number.
>    	 */
>   -	protected boolean validateCreditCardPrefixCheck(String cardNumber) {
>   +	protected static boolean validateCreditCardPrefixCheck(String 
>cardNumber) {
>
>    		int length = cardNumber.length();
>    		if (length < 13) {
>
>
>
>   1.18      +6 -6      
>jakarta-commons/validator/src/share/org/apache/commons/validator/GenericValidator.java
>
>   Index: GenericValidator.java
>   ===================================================================
>   RCS file: 
>/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/GenericValidator.java,v
>   retrieving revision 1.17
>   retrieving revision 1.18
>   diff -u -r1.17 -r1.18
>   --- GenericValidator.java	30 Apr 2003 21:17:48 -0000	1.17
>   +++ GenericValidator.java	30 Apr 2003 21:24:41 -0000	1.18
>   @@ -310,7 +310,7 @@
>        * @deprecated Use CreditCardValidator.validateCreditCardLuhnCheck() 
>instead.
>        */
>       protected static boolean validateCreditCardLuhnCheck(String 
>cardNumber) {
>   -      return 
>CreditCardValidator.getInstance().validateCreditCardLuhnCheck(
>   +      return CreditCardValidator.validateCreditCardLuhnCheck(
>                cardNumber);
>       }
>
>   @@ -321,7 +321,7 @@
>        * @deprecated Use 
>CreditCardValidator.validateCreditCardPrefixCheck() instead.
>        */
>       protected boolean validateCreditCardPrefixCheck(String cardNumber) {
>   -      return 
>CreditCardValidator.getInstance().validateCreditCardPrefixCheck(
>   +      return CreditCardValidator.validateCreditCardPrefixCheck(
>                cardNumber);
>       }
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail


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


Mime
View raw message