考虑一个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