Ten best practices every beginner should use..

Pages: 12
18.Never give up.
19.

Try this habit (where input is the variable and EXPECTED_VALUE is a const
1
2
3
4
if( EXPECTED_VALUE == input)
{
   // ...
}


instead of
1
2
3
4
if( input == EXPECTED_VALUE)
{
  //...
}


in order to avoid errors like this one

1
2
3
4
5
if( input = EXPECTED_VALUE)
{
  //  will always execute this block since assignment operator used 
  //  accidentally.  The compiler will catch this if the const is on the LHS
}
18. Use a debugger. They were made for a bloody reason.
19. Do your own fking homework.
closed account (z05DSL3A)
20: buy and read C++ Coding Standards: 101 Rules, Guidelines, and Best Practices By Herb Sutter, Andrei Alexandrescu.
Or other books along these lines...there will probaby be some suggesting posted after this... :0)
Topic archived. No new replies allowed.
Pages: 12