I'm using Swift, but I understand computed properties are a thing in a few other languages as well. I have the following case:
- var
bar
in classFoo
is changed throughout program flow. - vars
a
,b
,c
andd
are constrained tobar
's value so defining them as computed properties is a clean way to handle that. - the constraints are simple calculations that take
bar
and output a value
I can write the formula in the getter of each of the individual vars (the formulas vary slightly), or I could have the vars be normal properties and just assign them in bar
's set.
Which is more preferable? Is there anything more to consider than style?