On 27/06/2019 04:57, nate lust wrote:
However it is a fair point, that it might not be transparent and you could end up with an exception thrown at some point. I would argue this is not much different than using any library code where you would need to understand the api, but documentation is not always up to par, and it is indeed one more thing to think about or check for.
I'm afraid I think it's considerably worse than needing to understand a library's API. When I write something like:
dastardly.plane.state = DO_SOMETHING_MUTTLEY
I can accept that things might happen behind the scenes (Muttley might do something). I'm manipulating an object that the library has handed me, it's allowed to be a bit strange as long as that doesn't impinge on me much. Personally I would prefer a function interface as that's more explicit that magic may happen, but objects are (intuitively) allowed to be complex.
On the other hand, when I write:
meta_muttley = get_something_shiny_and_new()
I do not expect anything magic to happen. There is no contextual clue that what looks like a straightforward name rebinding is going to do something quite different, and not leave me with something shiny and new after all. Suddenly a name isn't a simple name any more, and it's not at all obvious.