以下函数名称是常规的:返回布尔值的函数的命名约定可能会让非英语母语者感到困惑。
然而,我想知道是否其他以动词开头而不是“is, are, can, has”等的函数名称也像以下内容一样传统:
bool is_valid();
bool is_sorted();
bool is_empty();
bool has_children();
bool can_draw();
然而,我想知道是否其他以动词开头而不是“is, are, can, has”等的函数名称也像以下内容一样传统:
bool TryToCloseWindow(); // check to see if the user tries to close the window
bool IntendToCloseWindow(); // as above
bool FileExists(); // check to see if the file exists
如果你是以英语为母语的程序员,你认为这三个函数名是否常规?