2 added 3 characters in body
source | link

As an addition to other answers. Use constants for strings when possible. Of course, you don't want to have

const string server_var="server_var";

but you should have

const string DoMySelect="selectMySelectQuery="select * from mytable;";

(assuming you actually have a query where you want to get all the results from a specific table, always)

Other than that, use constants for any number other than 0 (usually). If you need a permission bitmask of 255, don't use

const int 8th_bit=255; //or some other obscure naming scheme that equates to 255.

instead use

const int AllowGlobalRead=255;

Of course, along with constants, know when to use enumerators. The above case would probably fit well in one.

As an addition to other answers. Use constants for strings when possible. Of course, you don't want to have

const string server_var="server_var";

but you should have

const string DoMySelect="select * from mytable;";

(assuming you actually have a query where you want to get all the results from a specific table, always)

Other than that, use constants for any number other than 0 (usually). If you need a permission bitmask of 255, don't use

const int 8th_bit=255; //or some other obscure naming scheme that equates to 255.

instead use

const int AllowGlobalRead=255;

Of course, along with constants, know when to use enumerators. The above case would probably fit well in one.

As an addition to other answers. Use constants for strings when possible. Of course, you don't want to have

const string server_var="server_var";

but you should have

const string MySelectQuery="select * from mytable;";

(assuming you actually have a query where you want to get all the results from a specific table, always)

Other than that, use constants for any number other than 0 (usually). If you need a permission bitmask of 255, don't use

const int 8th_bit=255; //or some other obscure naming scheme that equates to 255.

instead use

const int AllowGlobalRead=255;

Of course, along with constants, know when to use enumerators. The above case would probably fit well in one.

1
source | link

As an addition to other answers. Use constants for strings when possible. Of course, you don't want to have

const string server_var="server_var";

but you should have

const string DoMySelect="select * from mytable;";

(assuming you actually have a query where you want to get all the results from a specific table, always)

Other than that, use constants for any number other than 0 (usually). If you need a permission bitmask of 255, don't use

const int 8th_bit=255; //or some other obscure naming scheme that equates to 255.

instead use

const int AllowGlobalRead=255;

Of course, along with constants, know when to use enumerators. The above case would probably fit well in one.