Commons Validator

Many times Developers are tempted to write their own validations.
If using Java, better to use “Commons Validator”

https://commons.apache.org/proper/commons-validator/

Few Points:
1. Always check for null. Don’t assume that customer will provide data.
2. Always check for boundary values….i.e min/max/…etc
3. Better to associate Error Messages with Error Codes. Pretty much required for Automation.
4. Externalize Strings to support multi lingual support
5. If not doing anything, don’t catch exceptions.
6. Don’t swallow exceptions….preserve the stack trace
7. Don’t convert exception A to exception B
8. Use Sonar and fix the values
9. Define constants separately….if possible configurable in future.

-0-

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s