Afficher un message
Vieux 24/02/2008, 08h13   #22
Phlip
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Monkeypatching is Destroying Ruby

James Britt wrote:

> It's no more "patching" than reassigning to a variable is patching.
>
> "ZOMG! You're changing something at runtime!"


That's not MP. MP is changing a published class by re-writing one of its
existing methods. Your whole program and all its modules get the new
version, at design time.

Otherwise, you have to...

- inherit that class
- override the method
- upgrade all the class objects' .new sites

The last one is the reason - without pristine Construction Encapsulation -
MP is the shortest path between two points.

So when we "use with caution", where highly popular libraries - obvious
example Rails - get to patch whatever they feel like, and modules below them
in the pecking order must refrain from patching so freely.

That's why I suggested encapsulating the patch effects to the patching
module. That's either a new feature in Ruby, or a very clever
metaprogramming hack. Problem solved.

--
Phlip


  Réponse avec citation
 
Page generated in 0,04339 seconds with 9 queries