Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Latest commit

 

History

History
174 lines (138 loc) · 3.52 KB

File metadata and controls

174 lines (138 loc) · 3.52 KB

| 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.

Capitalisation Rules for Identifiers

​ ​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_;
  ...
};

Compound Words and Common Terms

​ 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
email e-mail
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

Case Sensitivity

​ C++ are case-sensitivity.

See also

​ Other Resources


© 2020 Gammasoft.