Re: [请益] 写注解到底是不是好习惯

楼主: del680202 (HANA)   2018-12-30 17:31:46
※ 引述《bf000777966 (joe)》之铭言:
: 有些人以为逻辑程度好就不需要注解,但是语文能力(英文?)跟逻辑是一样重要的,精准
: 的命名也是需要一定的底子,如果连命名别人都看不懂还是多写点注解还能顺便增强语文能
: 力。
虽说前面打哈哈已经回了一篇
老实说我比较意外好像有人把clean code当圣经一样推广
写注解这件事 我自己的态度是
https://i.imgur.com/InnN0Wm.jpg
我不会期待其他人写code的能力有多高竿
同样一段逻辑就算用中文讲对方都不一定听的懂的
就算使用表达能力强的现代程式语言都不见得能省多少解读时间
拿我最近在hack的project来说
def reset_state_for_orphaned_tasks(self, filter_by_dag_run=None,
session=None):
"""
This function checks if there are any tasks in the dagrun (or all)
that have a scheduled state but are not known by the
executor. If it finds those it will reset the state to None
so they will get picked up again.
The batch option is for performance reasons as the queries are made in
sequence.
:param filter_by_dag_run: the dag_run we want to process, None if all
:type filter_by_dag_run: models.DagRun
:return: the TIs reset (in expired SQLAlchemy state)
:rtype: List(TaskInstance)
"""
我会很喜欢读这种代码
一个function,使用在什么情境 期待的input长什么样子等等
就像在看一个故事
我相信不少人都有看过类似程式码是艺术这种标语
但是醒醒吧 你的艺术 曲高和寡
https://i.imgur.com/tEv4vxy.jpg
作者: cuteSquirrel (松鼠)   2018-12-30 17:36:00
推荐这篇文章和意境
作者: pttworld (批踢踢世界)   2018-12-30 17:38:00
工程师的英文都不用太期待
作者: superpandal   2018-12-30 21:12:00
其实clean code是用来区分你跟他是不是同类的标准
作者: babelism (Bob)   2018-12-30 22:33:00
这只是类javadoc的API reference,和comment不同

Links booklink

Contact Us: admin [ a t ] ucptt.com