Skip to main content

Capitalisation Conventions

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.

Capitalisation Rules for Identifiers

​ ​As required by the ISO standard, use only lower case letters and numbers, separating words with underscores. Do not use capital letters to differentiate words, nor anywhere in identifiers. There is only one appropriate way to name identifiers:

snake_casing

​​property_descriptor
html_tag

✔️ DO To differentiate members form accessors or methods, 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:

io_stream
  • Naming :
namespace xtd {
class thread {
...
};
}
  • Type :
namespace xtd {
class thread {
...
};
}
  • Interface :
class ienumerable interface_ {
...
};
  • Method :
class control {
public:
virtual std::string to_string() const;
};
  • Event :
class list_control : control {
public:
event<list_control, event_handler> 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 unsigned_integer {
...
private:
unsignecd int value_;
};

struct date_time {
...
private:
long long value_;
date_time_kind kind_;
...
};

Compound Words and Common Terms

​ Most compound terms are treated as single words .

❌ 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_wordNot
bit_flagbitflag
callbackcall_back
canceledcancelled
do_notdon't
emaile-mail
endpointend-point
 file_namefilename
gridlinegrid_line
hashtablehash_table
idID
indexesindices
log_offlog_out
Log_onlog_in
metadatameta_data
multipanelmulti_panel
multiviewmulti_view
namespacename_space
okOK
piPI
placeholderplace_holder
sing_insign_on
sign_outsign_off
user_nameusername
white_spacewhitespace
 writablewriteable

Case Sensitivity

​ C++ are case-sensitivity.

See also