前面一段时间对 FP 和 OOP 两者的关系感到比较困惑
我使用的动态语言揉合太多范式, 在这一点上很难做出明确透彻的区分
不过经过这段时间琢磨相对之前感觉要好一些了, 有了一些自己的想法
后面自己的部分会有不少没有验证的地方, 所以应该当成感想来看
需要说明, 我的经验来自动态语言(JavaScript), 相对静态语言会有很多纰漏
网上的解释
当然这种事情先 Google 是必需的, 我当时微博标记了两份比较在意的说明:
我摘录的原文部分应该很有建设性, 就不翻译了:
When you anticipate a different kind of software evolution:
- Object-oriented languages are good when you have a fixed set of operations on things, and as your code evolves, you primarily add new things. This can be accomplished by adding new classes which implement existing methods, and the existing classes are left alone.
- Functional languages are good when you have a fixed set of things, and as your code evolves, you primarily add new operatio