what.is?(:monkey_patching)
The dynamic modifications of a class or module at runtime.
* A common pattern shared across Ruby community.
Slide 5
Slide 5 text
ruby.class.is(:open)
Slide 6
Slide 6 text
the (:good) -> { side }
extremely convenient, especially for hot-fix.
shorter code writing.
nicer DSL syntax.
Slide 7
Slide 7 text
The “beauty” of monkey-patching
Slide 8
Slide 8 text
But it’s just simply not worth it!
Slide 9
Slide 9 text
No content
Slide 10
Slide 10 text
No content
Slide 11
Slide 11 text
the -> (dark) { side }
global namespace pollution.
codes are more difficult to debug and understand.
poor upgradeability.
race condition of libraries.
…
Slide 12
Slide 12 text
– lotusrb
“zero monkey-patch of Ruby core and stdlib.”
Slide 13
Slide 13 text
but there are certain times that
patching becomes unavoidable
Slide 14
Slide 14 text
when(monkey.patch).makes_sense
the original libraries got a bug.
stubbing a method for testing.
…
Slide 15
Slide 15 text
MP.without { making.a(mess) }
Fork the library on Github.
Slide 16
Slide 16 text
No content
Slide 17
Slide 17 text
MP.without { making.a(mess) }
Fork the library on Github.
Put them into a module.
Slide 18
Slide 18 text
No content
Slide 19
Slide 19 text
MP.without { making.a(mess) }
Fork the library on Github.
Put them into a module.
Standardise the way of your monkey-patching files structure.
Slide 20
Slide 20 text
No content
Slide 21
Slide 21 text
MP.without { making.a(mess) }
Fork the library on Github.
Put them into a module.
Keep them together.
Use Ruby refinements.