←back to thread

498 points azhenley | 1 comments | | HN request time: 0.211s | source
Show context
nixpulvis ◴[] No.45771961[source]
I try to keep deeper mutation to where it belongs, but I'll admit to shadowing variables pretty often.

If I have a `result` and I need to post-process it. I'm generally much happier doing `result = result.process()` rather than having something like `preresult`. Works nicely in cases where you end up moving it into a condition, or commenting it out to test an assumption while developing. If there's an obvious name for the intermediate result, I'll give it that, but I'm not over here naming things `result_without_processing`. You can read the code.

replies(5): >>45772035 #>>45772551 #>>45773468 #>>45775029 #>>45776914 #
nailer ◴[] No.45772551[source]
result.process()

That doesn’t make logical sense. You already have a result. It shouldn't need processing to be a result.

replies(1): >>45773269 #
riskable ◴[] No.45773269[source]
It also doesn't make sense for `process()` to be an attribute of `result`. Why would you instantiate a class and call it result‽
replies(2): >>45773534 #>>45775586 #
1. feoren ◴[] No.45775586[source]
> Why would you instantiate a class and call it result‽

Are you suggesting that the results of calculations should always be some sort of primitive value? It's not clear what you're getting hung up on here.