【发布时间】:2020-01-15 14:04:01
【问题描述】:
考虑一个 Python 模块(但它与其他语言相关),其中包含一系列旨在按顺序使用的函数。 即,函数根据以下方案在语义上链接:
def function_a_to_b(thing_a):
"""Compute the thing_b."""
thing_b = thing_a**2
return thing_b
def function_b_to_c(thing_b):
"""Compute the thing_c."""
thing_c = thing_b**3
return thing_c
在这个简单的示例中,function_a_to_b 的候选名称可以是 squaring 和 thing_a 可以命名为 square,同样我们可以使用 cubin 和 cube。
现在,如果thing_a 是不支持动词的复杂事物,请说weighted_glonk。
我如何命名function_a_to_b 以保持简短、明显,并避免变量冲突或容易出错的命名空间细节?
对于该功能,我倾向于compute_weighted_glonk。另一种选择是匈牙利命名,比如array_weighted_glonk
【问题讨论】: