Dne 29.8.2013 14:47, Roman Neuhauser napsal(a):
# dmajda@suse.cz / 2013-08-29 10:15:30 +0200:
Now suppose I'd "expect the unexpected" and would want to check if a default is used. Now I'd encounter the *visibility* problem. I'd have to look where the hash is created and see if a default is set there. And that by itself is not enough, because the default could be set even at some later point, meaning any code that touches the hash is suspect. As a result, I could spend quite some time just by ensuring that the hash has no default.
this is a great argument against reopening classes or monkeypatching, basically against ruby. ;)
Yes, I'm aware of it :-) Nothing is black and white and one has to think about degrees of various positive and negative effects (even of the same kind) in different situations. In case of hashes with defaults, the positive effects seems small (a bit of DRY) and the negative ones large (big surprise at call site). This is amplified by the possibility to solve the problem differently (as pointed out by Ladislav in another reply to my mail). In other situations (say, RSpec adding "should" method to all objects), the situation isn't that clear (at least to me). -- David Majda SUSE Studio developer http://susestudio.com/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org