Meta programming can be disastrous. While it is cleaner in many cases, it must be used with prudence. This talk will cover the issues that arise from irresponsible meta-programming like overuse of method_missing, ""monkey patching"", and eval.
'method_missing' can be used to create methods on the fly. What people don't realize is that method_missing is called when you typed in an error, and you may define error handling code for this. While it may be easy to create dynamic methods this way, those methods are never actually defined and therefore cannot be documented properly. Instead I will explain the use of define_method which is much more suitable in 80% of cases.
Monkey Patching, or adding methods to an existing class, is also dangerous. Being able to override functions like ""freeze"" is extremely dangerous. Instead I suggest a better way of overriding methods on single objects instead of classes.
Join me on a meta-programming safari where we will learn responsible meta-programming
Sign in to add slides, notes or videos to this session