※ 引述《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