All professional programmers have certain things they absolutely abhor when it comes to C++ programming, and of course half the engineers in the company do it.
Which ones do you hate the most?
To start it off, here's four of mine in one example:
1 2 3 4 5 6 7 8 9
|
bool SomeFunction() {
bool result;
result = false;
if( SomeOtherFunction() == false )
result = false;
else
result = true;
return result;
}
|
1. Doing in 10 lines of code what could have been done in 1. 'Nuff said.
2. Declaring an uninitialized variable on one line, then initializing it on the very next line.
3. "Some booleans aren't true or false enough to be assigned to other booleans." Why not result = SomeOtherFunction()???
4. Not returning when there's nothing else to do. (The "one return per function" rule).
Two more of mine:
5. Not using an initializer list in the constructor. Instead, assign each element in the body of the constructor.
6. Not even bothering to write a constructor for a value class; instead just have the calling code willy-nilly initialize data members whereever/whenever it feels like it, so that when you need to go add new elements to the class, you have to manually find every instantiation of it to ensure the new element gets initialized in all cases.