Mailinglist Archive: yast-devel (144 mails)

< Previous Next >
Re: [yast-devel] Questions about some YCP Equivalents in ruby
Dne 29.8.2013 14:47, Roman Neuhauser napsal(a):
# dmajda@xxxxxxx / 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
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups