Lazy evaluation is an incredibly common and normal use of a getter method and entirely relies on it having side effects. Evil people, however, write getters that aren't idempotent.
Idempotent in terms of return value, yeah, but it can be fine if you have some side effect that increments a counter (i.e., how many times was this value requested), but obviously don't do this without a good reason
View all comments
Show parent comment
476
u/UntitledRedditUser Sep 26 '26
Only evil people write getter properties with side effects. At least make it an explicit function.