Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Use monkey patching in tests, never in production.

My worry about that argument is: how do you audit your code base to make sure you really aren't relying on monkey patching in production code?

This is a concern with any abstraction technique that provides neater code by hiding some part of the behaviour, starting with simply using a programming language at a higher level than assembly.

However, in some cases, particularly more static/compiled languages, there are often tools to enforce encapsulation of various kinds. On that basis, you can systematically prove that the code you're looking at really does honour certain guarantees.

In the dynamic/interpreted languages, this can be harder, because with so much being done at run-time and so much flexibility, almost everything comes down to trust. That makes it more difficult to move from informal/convenient to formal/rigorous code as a project evolves.

Often, that may be a price worth paying. In return we can get early prototypes up and running more quickly than we could with a heavier "engineering" language. But we shouldn't underestimate the long-term implications of that trade-off.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: