For "zip code" do you mean US zipcodes? UK postcodes? Any of them? All of them?

I think if there is a "standard zipcode" definition within your company/project/application, then those for attributes are related, and it would make sense to create an separate class for dealing with them. But I would assume such a class to have considerably more functionality that just validation.

If the only constraint on those disparate fields is that they must be positive integers (what size?), then you can probably get away with making them a type.

However, if we are talking about 4 truely disparate and unrelated attributes of 4 truely unrelated classes, that just happen to require a similar type of validation--at the moment--then it would be downright dangerous to use a common routine for performing that vaidation. As soon as one of them changes, the nature of their unrelatedness is likely to cause the the maintenance programmer to modify the validation routine commesurate with the one that changed and be completely oblivious to the other three which haven't.

Finally, if there are sound reasons for using a single vaidation routine for the 4 disparate attributes, I would just call that routine within the second code block of the LVALUE keyword I described. It in no way precludes that.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

In reply to Re^19: Assignable Subroutines by BrowserUk
in thread Assignable Subroutines by dragonchild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.