This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
In my current project I am trying to promote the use of org.apache.commons.lang utility classes to help do input validations for forms (still working towards getting the team to use the Validator). Right now there are a number of helper methods in the base ActionForm and more are getting added as I write. Examples of what I'm trying to do: - deprecate BaseForm.isEmpty(String); use org.apache.commons.lang.StringUtils.isBlank(String) instead - deprecate BaseForm.isIntegral(); use org.apache.commons.lang.StringUtils.isNumeric(String) or or ...lang.math.NumberUtils.isDigits(String) instead
I'd like to put together a list of pros and cons of the current practice, hoping to show that there are more cons than pros. The only pro right now is convenience - you don't have to import another class; you can just call the method directly. The cons I have are: 1. Methods like these really should be in a statics-only Utility type class (thus the push to use commons.lang classes). 2. The methods pollute the BaseForm object. 3. The validation code is coupled to the Form (right now they're instance methods). If you want to reuse the validation code somewhere else, it won't make sense to instantiate a form then call the method. (Of course it would be argued that doing so would be silly and that a solution would be to make the methods static, but still keep them in the Form. Still bad but I just know it's going to be said). My concern is that it can be argued that these (both pro and cons) are just a matter of aesthetics/form; that there is really no advantage or disadvantage of doing it one way or the other. I know there must be other more compelling reasons against the current practice but I can't seem to find the right search criteria to find them. Any help or suggestions would be appreciated. [ February 12, 2004: Message edited by: Junilu Lacar ]