arborint wrote:The part of the code you left out is how "hasLengthOf" is mapped onto "Zend_Validate_StringLength". If the mappings are internal then your class is monolithic.
The mappings would either be automatically wired by naming convention, i.e, the alias
stringLenth automatically maps to
Zend_Validate_StringLength (i.e., uppercase first letter and prepend "Zend_Validate_");
Or they would be automatically wired by configuration, i.e, some type of a configuration mechanism (be it file, code, or otherwise) that allows mapping the alias
stringLenth to
Zend_Validate_StringLength.
The first is easier to implement, but prone to problems in larger systems because there can be no naming collisions. Thus it is also less flexible because you cannot swap out a "default" validator for a different one using the same alias.
The second involves a little more work in implementing, but is ultimately much more flexible, because it does not rely on convention, so you could overwrite mappings, for example re-map
stringLenth to
Zend_Validate_UTF8StringLength instead of
Zend_Validate_StringLength.
You could even do both, allow configuration, and default to convention in the absence of it.
[public] interface complexity is not -- or should not be -- synonymous with flexibility. It is quite possible to have a simple [public] interface that affords just as much [or more] flexibility as a complex counterpart does. Quite frankly I am getting a little tired of programmers assuming that something seemingly relatively simple cannot be highly flexible. That is, how should I say, a cop out position, no offense intended towards you.
It's a bit counter-intuitive, because the validator system as a whole would be required to grow more complex to allow the public interface to the system to grow more simple. It's a concept knows as "simplexity", making increasingly complex things appear to be simple. It's one of my core development values that I try to achieve in everything I do. Really I think all developers should adopt it as a core value, though some (or many) will not agree. It's a modern world and simplexity is growing increasingly popular. Look at nature; all of nature for the most part is simplexity. Or look at new technology. Many of the new gadgets appear to be quite simple to use, ie. they have a simple public interface, but are in fact quite complex pieces of technology if you peer beneath the facade that is their user [public] interface.