by Dominic Zukiewicz
18. December 2007 14:13
Enumerations are great when something can only be a set of fixed values - normally ints.
Another good reason, is when you do a .ToString(), you actually get the variable NAME! Brilliant!
But ..... what if you wanted to keep your variable names, but you wanted to add an additional description to improve the understanding of it? I'll give an example.
In some legacy systems, variables are named very cryptically, well compared to the OO languages because of the limit of characters for variable names, or because developers wanted some short hand method to access them, if you were an expert! So I'll make some values up, hopefully similar to the found in a live system...
Type:
ACCUR = Current Account = 1
ACCHQ = Cheque Account = 2
ACCSH = Cash Account = 4
Status:
ACCRT = Account Created = 1
ACSUS = Account Suspended = 2
ACCLO = Account Closed = 4
ACDEC = Deceased Account = 8
ACFRA = Fraudulent Account = 16
ACOPN = Account Opened = 32
ACTFN = Account Transferred = 64
Payment Types:
ACSOO = Standing Order Payment = 1
ACMIP = Monthly Interest Account = 2
ACDDP = Direct Debit Payment = 4
Luckily, I've given you these descriptions, whereas you normally have to source out a developer to explain these terms for you. When talking to them, verifying these at a later date, the developer of the legacy system will most likely talk to you in terms of the 5 character codes. You have 2 options really. One is to use your own variable naming and use commenting to go back and forward with these, OR you can create your own custom attributes, and store them there!
0e08e94e-c424-4d82-a289-00db622a0a08|0|.0
Tags: