如何安全地重构动态语言?

How to refactor dynamic languages safely?

例如我决定融合两个类。 JS 或 LUA 的问题是很难找到隐含的问题,例如,只有当你的运行时实际执行你试图实现的代码片段时,它才会向你显示错误。像 Haxe 或 C++ 这样的严格语言的优点是,在你修复所有问题之前,你的代码不会编译。

有谁知道重构动态语言的最佳实践是什么?

这个问题并不是 "refactoring" 特有的。

就是那个"it (the dynamic language interpreter) shows you a error only when your runtime actually executes the piece of code which is wrong (and sometimes not even then)"。这大概是动态语言的一大缺陷吧。

我们需要的是一种工具,它可以对您的代码进行深入推理,以便在可行的情况下静态决定是否执行它可能会产生运行时错误或无用的计算。这样的工具很难找到。

这里的讨论很有启发性:Programming Language Properties that facilitate refactoring?