T
The Last Gunslinger
What are peoples views on using readonly properties to return the sum of
a calculation?
For instance you might have a invoice class that has itemprice and
quantity properties.
Would the total be implemented as readonly prop Total to return
itemprice * quantity or method CalculateTotal which returns the same thing.
A readonly prop is, IMHO, more intuitive as it is still an attribute of
this class but what about when you have a longer calculation that
affects performance and as such should be stored by the consumer instead
of running the calc every time they wanted to access the 'property'.
I dont think there is a 'right' way to do this but I need to define a
clear rule for programming standards to be implemented in a company.
Thanks for your input.
JB
a calculation?
For instance you might have a invoice class that has itemprice and
quantity properties.
Would the total be implemented as readonly prop Total to return
itemprice * quantity or method CalculateTotal which returns the same thing.
A readonly prop is, IMHO, more intuitive as it is still an attribute of
this class but what about when you have a longer calculation that
affects performance and as such should be stored by the consumer instead
of running the calc every time they wanted to access the 'property'.
I dont think there is a 'right' way to do this but I need to define a
clear rule for programming standards to be implemented in a company.
Thanks for your input.
JB
