Wednesday, August 5, 2009

A minor case code that to me is more complicated and less correct than it needs to be is validation of email address formats done in code where I work. It's pretty much always done with a regular expression. The JavaMail API is always available too. javax.mail.internet.InternetAddress.parse() will throw a javax.mail.internet.AddressException for invalid email address formatting, so why are regular expressions always used? I'm guessing that it's ignorance and coding by copying. It works well enough, so I'm not going to change it. But I'd do email address format validation with JavaMail rather than with a regular expression.

No comments:

Post a Comment