gpt4 book ai didi

naming-conventions - 如何命名变量 : numItems or itemCount?

转载 作者:行者123 更新时间:2023-12-03 10:23:58 26 4
gpt4 key购买 nike

命名变量的正确方法是什么

int numItems;

对比
int itemCount;

或常数:
public static final int MAX_NUM_ITEMS = 64;

对比
public static final int MAX_ITEM_COUNT = 64;

最佳答案

在“Code Complete”中,Steve McConnell 指出“Number”是不明确的。它可以是一个计数、一个索引或其他一些数字。

"But, because using Number so often creates confusion, it's probably best to sidestep the whole issue by using Count to refer to a total number of sales and Index to refer to a specific sale."

关于naming-conventions - 如何命名变量 : numItems or itemCount?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6358588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com