c语言sscanf函数的用法是什么
262
2022-10-31
前端函数式 -- 1. 为什么要用函数式编程(以JS为例)
最新文章请访问我的个人博客 teobler.com
首先需要说明的是,这篇文章是以JS为例的,而JS并不是一个以函数式设计的语言,它仅仅是可以做到函数式,那么既然如此我为何还要以JS为例呢?很简单,因为我是一名前端,目前我只会JS。第二个前提条件是,我们假设所有你参与的项目不可能是你一个人完成的。
函数式编程在React团队推出Hooks方案之后在前端领域算是掀起了一股小热潮,于是在各大网站上一些问题的热度突然就起来了,比如为啥要用函数式编程?而为了解释这个问题,就不得不提到两个编程思想。
命令式编程更加注重于**如何(how)**去实现某件事。
people always says, comments is a eval, if code has comments, that's means the code is terrible. Code need to self document itself. I would say no, Code doesn't need to self document itself. Code needs to tell a story, it needs to communicate, that's for true.There is a purpose for code comments. They're not an excuse for not caring about your code. A lot of people will go to the other extreme and say, what does it matter how bad the code as long as there's a code comment, and I explanined what I was doing.A bad code comment is worse than no comment at all. You don't have to remove all comments, but your comment should not duplicate the narrative of what the code is doing. comments should explan why, not how, sometimes maybe it needs to focus on the how if it's particularly confusing, if theres's something particularly hard to understand. what if your code made it obvious why it was doing something.
可读性
这个时候一定会有人吐槽:兄嘚,别忽悠了,我们组张三在组里推函数式,他那代码,我打包票,三天后他自己都看不懂。
兄弟,别急,坐下来喝口水,我们继续来看看这张图:
于是有一大批人在这个节点放弃了,并且加入了吐槽的大军中去,函数式可读性高?高个P,写出来的全是意大利炮面条。另外一部分人坚持下去了,并且开始逐渐理解函数式,在加强的函数式的各种理解后,代码的可读性终于在谷底反弹,并渐渐超越了过去的自己。
小黄书的作者Kyle用了3年让自己成为了一个函数式的工程师,他说自己在这中间也想过要放弃,在中间位置的部分比你想象的还要糟糕,所以如果你也想要尝试,那么请不要放弃,这不是一朝一夕能够改变的。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~