I too like 'wrap' and find it reliable; it provides me with an ideal string to write to or read from databases and still be able to reconstruct the original object.
Why do variables have versions? At any given point of reference, there is only one version (that is, value) of any variable. However, there are many points of reference in real life. Some examples:
1. an individual may have only one surname at a time but over time may have several (surnames may change upon being married, divorced, remarried etc. etc.)
2. a variable holding, say, tax rate will have only one value at a time but over time, it will have had several values.
3. seemingly unchangeable data may also have several versions; for example, if a date of birth was entered incorrectly and then corrected, you may want to know the duration or time span during which the incorrect date of birth was used.
For practical purposes, there may be several values for , say, discount rate: it may vary by (size of) client, age of client i.e. there may be introductory rates for a period and then a 'normal' rate. In a database table:
Client Discount
ABC 1.05
DEF 1.09
...
XYZ 1.03
The application will have a variable Discount, given a Client: the computation remains the same:
- Code: Select all
Discount ← get from database according to client & other criteria
AmtDue←Cost ÷ 1 + 0.01 × Discount
This simplifies coding: the alternative is:
- Code: Select all
∇ Z←Client GetAmtDue Cost
[1] :select Client
[2] :case 'ABC'
[3] Z←Cost ÷ 1+ 0.01 * 1.05
[4] :case 'DEF'
[5] Z←Cost ÷ 1+ 0.01 * 1.09
[6] :case 'XYZ'
[7] Z←Cost ÷ 1+ 0.01 * 1.03
[8] :endselect
∇
This has the additional overhead that if the rates change, the code needs to change as well.
Besides, you mentioned version control - isn't that a recognition that objects (data or code) changes?