All,
I'm developing an application using Zend Framework to manage tenders for construction work.
The tender will be a rather complex set of models with an architecture resembling the code snippet below.
My question is... should I store the total value of the tender as part of the tender model, or should I compute it each time it is required? The total value of the tender will be a sum of all the components (e.g. plant/labour/materials/overheads/etc).
object(Application_Model_Tender)#75 (4) {
["_id":protected] => int(1)
["_name":protected] => string(33) "Tender Name"
["_due":protected] => string(10) "2010-12-01"
["_labour":protected] => array(2) {
[0] => object(Application_Model_Gang)#81 (3) {
["_id":protected] => int(1)
["_name":protected] => string(25) "First Gang Name"
["_gangMembers":protected] => array(2) {
[0] => object(Application_Model_GangMember)#93 (5) {
["_id":protected] => NULL
["_name":protected] => string(11) "Labour Type"
["_workingPattern":protected] => string(7) "Default"
["_cost":protected] => float(546)
["_qty":protected] => int(3)
}
[1] => object(Application_Model_GangMember)#91 (5) {
["_id":protected] => NULL
["_name":protected] => string(11) "Labour Type"
["_workingPattern":protected] => string(8) "Custom 1"
["_cost":protected] => float(777)
["_qty":protected] => int(1)
}
}
}
[1] => object(Application_Model_Gang)#90 (3) {
["_id":protected] => int(2)
["_name":protected] => string(15) "Second Gang Name"
["_gangMembers":protected] => array(1) {
[0] => object(Application_Model_GangMember)#92 (5) {
["_id":protected] => NULL
["_name":protected] => string(11) "Labour Type"
["_workingPattern":protected] => string(8) "Custom 1"
["_cost":protected] => float(777)
["_qty":protected] => int(2)
}
}
}
}
}