incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Mclean <jus...@classsoftware.com>
Subject Re: [Proposal] Add PostCodeValidator and PostCodeFormatter to the SDK
Date Sun, 11 Mar 2012 02:27:10 GMT
 Hi,

> What is the 1.5? We should try and not use any magic numbers/strings.

A few lines above is the following comment.
 // We want invalid char and invalid format errors to show in preference
// so give wrong length errors a higher value

Re magic number string I agree in general but in this case my reasoning at the time was not
to as:
1. It totally internal to that one function
2. It's only used in one place and I can't see the potential for it to be used elsewhere 
3. It actually value is meaningless (just has to >1 and <2)

It is possible that this  would be a tiny bit clearer.
Number(invalidFormat) + Number(invalidChar) + Number(incorrectFormat) + Number(wrongLength)
* IMPORTANT_ERROR

If you look at the other validators they have hard coded strings and values all over the place.
This code is most likely of a higher standard that what already exists in the Flex SDK both
as originally submitted and with all the changes based on feedback.

If it really offends anyone that much please submit a patch :-) And don't forget to run the
unit tests!

Thanks,
Justin
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message