-
Notifications
You must be signed in to change notification settings - Fork 7
Development Specifications
ref: https://google.github.io/styleguide/cppguide.html
Mainly follow Google naming conventions
File names must be all lowercase and may contain underscores (_)
player_info.cc
player_info.h
Each word in the type name starts with a capital letter and does not contain underscores: MyExcitingClass, MyExcitingEnum. All type names—classes, structures, typedefs, enumerations use the same convention
Variable names should always be lowercase, and words should be connected with underscores.
The member variables of the class end with an underscore, such as my_exciting_local_variable, my_exciting_member_variable_
Function names begin with a capital letter, with the first letter of each word capitalized, and no underscores: AddTableEntry()
Class' member set or get function:
class MyClass {
public:
...
int num_entries() const { return num_entries_; }
void set_num_entries(int num_entries) { num_entries_ = num_entries; } private:
int num_entries_;
};
lowercase + underline
player_info.lua
Camel case method, capitalize the first letter [lua file name and class name are consistent]
Item = class("Item");
Camel case, capitalize the first letter
function Item:UpdateData(data)
end
Local variable: Variable names should always be lowercase, and words should be connected with underscores.
Global variable: The first letter of global variables is capitalized, camel case
Const variable: uppercase and underlined
All capital letters, multiple words separated by underscores
ENUM.CHAT_TYPE =
{
WORLD = 1,
WHISPER = 2,
}
-- if..then..end、for..do..end、while..do.end、return、break, Each in its own line
for k,v in pairs(v) do
end
if i == 1 then
return true;
end
while true do
if i > max then
break;
end
end
ref: https://blog.csdn.net/diechenchen/article/details/108433899