命名那些事
其中使用驼峰和蛇式居多,而匈牙利命名法这种方法实在是反人类。
这里引用2位大师的吐槽
Robert C. Martin:
… nowadays HN and other forms of type encoding are simply impediments. They make it harder to change the name or type of a variable, function, member or class. They make it harder to read the code. And they create the possibility that the encoding system will mislead the reader.
Linus Torvalds :
Encoding the type of a function into the name (so-called Hungarian notation) is brain damaged—the compiler knows the types anyway and can check those, and it only confuses the programmer.
在变量前面加入类型前缀这种做法没有任何帮助,只能让代码难以阅读,让大脑受伤.
编译器知道类型检测,无需画蛇添足.
MindMapping Source:
1 | * Naming |