Look, what is so innately wrong with monkey-patching? You mention it in a distinctly perjorative tone, but why? Yes it can be used badly, but it can also be bloody brilliant.
Bad monkey-patching: touching any method defined in core.
Good monkey-patching:
class Array
def to_sentence
return "I contain #{self[0..-2].map {|x| x.to_s + ', '}}and #{self[-1]}."
end
end
Seriously, being able to do throw that kind of thing into the beginning of your program, extend the core classes just like that, is frickin' awesome.People abuse it, yes, like people abuse any power they're given. Just last week I wasted several hours trying to fix some strange ActiveRecord errors which turned out to be the morons in Rails Core monkeypatching Hash#to_json; my solution ended up being monkeypatching it straight back. Great. Obviously, I wish I didn't have to do that kind of thing.
However - don't blame the technique, blame the people who misuse it. Used properly, it can be a dream come true. Always wish that Time could print to string including milliseconds? Baby, I've got Time#to_s_usecs for you in three lines of code.
Monkeypatching is a sharp knife - you can cut your bread or you can cut yourself. Either way, it's not the knife's fault. And either way, I'd rather have a knife than not have one : )