A mostly reasonable approach to C++.
Use auto to avoid redundant reputation of type names and simplify generic code.
DO:
auto age = GetAge();DON'T:
int age = GetAge();Spaces are preferred to allow consistent alignment across different environments.
DO:
Foo device;
device.id = 1;
device.instance = CreateInstance();
device.style = FOO | BAR | BAZ;DON'T:
Foo device;
device.id = 1;
device.instance = CreateInstance();
device.style = FOO | BAR | BAZ;MyFile.cppclass MyClass {...}class Foo
{
public:
void MyMethod();
}class Foo
{
public:
int MyPublicProperty;
}class Foo
{
private:
int my_private_field_;
}void Foo::Bar(int my_parameter) {...}void Foo::Bar()
{
auto my_variable = 1337;
}The compiler and IDE can provide type information, prefixing this information is redundant and gets in the way of reading the code.
DO:
std::string username = "batman";DON'T:
std::string strUsername = "batman";