Skip to content

e_param members easily confused with variables #134

@SimonCROS

Description

@SimonCROS

Enum e_param declares values with the same naming convention as private variables.

typedef enum {
channel_,
hostname_,
key_,
message_,
flag_,
flagArg_,
nickname_,
password_,
realname_,
servername_,
target_,
topic_,
username_,
} e_param;

Usages of these variables, for example in CmdManager.cpp

log(CmdSpec::CmdBuilder()
.Name("PASS")
.Registration(0)
.addParam(password_, new CmdParam())
.addChecker(check::register_::stageDone)
.addChecker(check::register_::isRegistered)
.addChecker(check::enoughParams)
.addChecker(check::register_::pwMatch)
.CmExecutor(pass)
.build());

it's hard to distinguish password_ from a variable.

A common convention in C++98 is to use PascalCase for enumeration members, starting with the enumeration name to avoid conflicts (scoped enumeration appeared in C++11).

e_param might look like this

enum ParamType {
	ParamTypeChannel,
	ParamTypeHostName,
	ParamTypeKey,
	ParamTypeMessage,
	ParamTypeFlag,
	ParamTypeFlagArgument,
	ParamTypeNickname,
	ParamTypePassword,
	ParamTypeRealName,
	ParamTypeServerName,
	ParamTypeTarget,
	ParamTypeTopic,
	ParamTypeUserName,
};

Also, in C++, an using an enum does not require the enum keyword (same thing with struct), so typedef is useless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions