| Home | Downloads | Examples | Documentation | Sources | Project | Contact | Gammasoft |
The guidelines in this chapter lay out a simple method for using case that, when applied consistently, make identifiers for types, members, and parameters easy to read.
As ISO Standard, use lower case only and digits, separate words with underscores. Do not use capitilise to differentiate words, or for that matter, anywhere in identifiers
property_descriptor
html_tag√ DO To differenciate members form accessors or metods, end members by _.
namespace xtd {
class my_class {
public:
int value() const {return value_;}
private:
int value_ = 42;
};
}A special case is made for two-letter acronyms in which both letters are not separed, as shown in the following identifier:
iostream- Naming :
namespace xtd {
class thread {
...
};
}- Type :
namespace system {
class thread {
...
};
}- Interface :
class ienumerable {
...
};- Method :
class control {
public:
virtual std::string to_string() const;
};- Event :
class list_control : control {
public:
event<list_control, event_handler<control&>> selected_index_changed;
};- Field :
struct unsigned_integer {
static constexpr unsigned int min = 0;
};- Enum Value :
enum class values {
append,
...
};- Parameters :
class convert {
public:
static int to_int32(const std::string& value);
};- Members : end by _
struct uint32 {
...
private:
uint value_;
};
struct date_time {
...
private:
int64_t value_;
date_time_kind kind_;
...
}; Most compound terms are treated as single words .
X DO NOT separate each word in so-called closed-form compound words. These are compound words written as a single word, such as endpoint. For the purpose of casing guidelines, treat a closed-form compound word as a single word. Use a current dictionary to determine if a compound word is written in closed form.
| separate_word | Not |
|---|---|
| bit_flag | bitflag |
| callback | call_back |
| canceled | cancelled |
| do_not | don't |
| endpoint | end-point |
| file_name | filename |
| gridline | grid_line |
| hashtable | hash_table |
| id | ID |
| indexes | indices |
| log_off | log_out |
| Log_on | log_in |
| metadata | meta_data |
| multipanel | multi_panel |
| multiview | multi_view |
| namespace | name_space |
| ok | OK |
| pi | PI |
| placeholder | place_holder |
| sing_in | sign_on |
| sign_out | sign_off |
| user_name | username |
| white_space | whitespace |
| writable | writeable |
C++ are case-sensitivity.
Other Resources
© 2020 Gammasoft.