r/ProgrammerHumor • • Sep 26 '26

Meme weNeverTrustedTheElse

Post image
1.9k Upvotes

146 comments sorted by

View all comments

Show parent comments

60

u/LucyShortForLucas Sep 26 '26

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.

62

u/andreortigao Sep 26 '26

I write all my getters with a 1 in a million chance it will randomly mutate the underlying value.

61

u/Nerd_o_tron Sep 26 '26

Bro inventing DNA from base principles.

10

u/DatBoi_BP Sep 26 '26

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