in reply to OO, Class::MethodMaker, and get_set
If C isn't settable, and is derived from A and B, it isn't an attribute, it's a result or returned value.
If the parameters are many, and the calculation is expensive, then re-calculating the results each time an attribute is set, rather than waiting until the result is requested will mean that many expensive calculations will be done, only to be discarded if more than one attribute can change between results being needed.
Better to allow Class::MethodMaker to define your setter and getters on the attributes and only perform the calculation when the result is requested via your hand-coded method for this purpose.
If you need to cache the results for efficiency, retain an internal copy of the attributes used along with the calculated result and only recalculate if they have changed.
|
|---|