posted 23 years ago
The statement nameLength += 2; involves typing two fewer characters, but is otherwise no more effective than the longer version, nameLength = nameLength + 2; and is neither more nor less readable. Using the += assignment operator is a good practice, however. If nameLength were a more complex expression, such as nameLength[ temp.calculateOffset( 5 ) + blanks++ ].item, it is definitely more readable to express incrementing this value by 2 using the += form. This is because the original programmer runs the risk of not coding the nameLength... parameter exactly the same on both sides of the = sign, and because a maintainer has a much easier time of recognizing what is happening, without having to read both complex expressions to determine that they are the same.