2 ms·
> You tend to not put temporary results of loops in instance variables, but in local variables. Which aren't visible externally at all. Cool! Then it follows
by mrkeen 4y ago
> You tend to not put temporary results of loops in instance variables, but in local variables. Which aren't visible externally at all.
Cool! Then it follows:
If a result is not temporary, then it can be immutable. Properly immutable, not just final.
If a result is temporary, then it is not to be visibly external at all. Not as a field, and not via any getter.
I could live with that.
- mpweiher 4y agoThat doesn't follow. Objects do (much) more than implement algorithms in loops. In fact, I'd say that if you're doing algorithms as objects, you're almost certainly Holding it Wrong™. Algorithms tend to be perfectly fine contained in a method of an object.