Hmm, this seems very similar to questions you've asked before about coordination of constants between a database and code. I think the only complete answer to avoiding this duplication is to make one or the other the master, and update automatically. For example, your perl code could check that types table at startup and update it to match the constants defined in your class. You can't really go the other way around in this case, since your code has specific behaviors that only apply to pending POs, and thus has to be able to "know" which type means pending.
As with the last time though, I think you're worrying about it much more than you should be. You don't have the IDs hard-coded all over the place; you have them hard-coded in one obvious place (POStatusType) that you could change quickly.
One thing I would do differently is abstract the fact that these type IDs exist at all by hiding them behind a set of method calls like PurchasOrder->is_pending(). Then you get a little more isolation from that stuff if you ever decide to change it.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.