我应该美元的C#p $ PFER静态方法静态、美元、方法、PFER

由网友(在我怀里睡)分享简介:已经花了一点时间来学习函数式编程,它变得越来越自然,我想与不执行任何突变的静态方法来处理。Having spent a bit of time learning about functional programming, it's becoming more and more natural for me to wa...

已经花了一点时间来学习函数式编程,它变得越来越自然,我想与不执行任何突变的静态方法来处理。

Having spent a bit of time learning about functional programming, it's becoming more and more natural for me to want to work with static methods that don't perform any mutation.

是否有任何理由为什么我要遏制这种本能?

Are there any reasons why I should curb this instinct?

推荐答案

这个问题我觉得有点古怪,因为静态方法和方法执行没有突变的方法两个正交分类。你可以有变异的静态方法和nonmutating实例方法。

The question I find a bit odd, because static methods and methods that perform no mutations are two orthogonal classifications of methods. You can have mutating static methods and nonmutating instance methods.

对于我来说,这已经成为越来越多的自然功能和面向对象编程结合起来;我喜欢的实例的方法执行没有突变。函数式编程更容易理解,因为它阻碍了复杂的突变;面向对象编程更容易理解,因为code和它的运作上的数据彼此靠近。为什么选择?拥抱和的力量;一举两得!

For me, it has become more and more natural to combine functional and oo programming; I like instance methods that perform no mutations. Functional programming is easier to understand because it discourages complex mutations; OO programming is easier to understand because the code and the data it operates on are close together. Why choose? Embrace the power of "and"; do both!

阅读全文

相关推荐

最新文章