首页 > 代码库 > Functional Programming.
Functional Programming.
I have been seeing Redux for sometime, but recently I come to realize that , it‘s part of so called functional programming.
The basic idea for functional programming is so simple,
- Declare all dependency as function input, no hidden input ( we should not directly used data in shared scope without passing it to input ).
- Return something ! We should not just manipulate data in shared scope inside function, instead, return something as result.
By doing these, we are creating a pure function , which doesn‘t have any side effect on shared scope.
The cons of this also comes quite obvious.
- The functions no longer mess around with shared scope, it‘s easier for people to work on same part.
- It‘s so simple to review code, by just examining input and output, one can know what the function does.
- It‘s even easier for testing. As we are using pure functions, we don‘t have to mock shared data any more. Give input and check output, that‘s all.
Functional Programming.
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。