The easiest source code to understand is that which shows only the necessary activity.  Consider the following example:

int width = 0;
int height = 0;
width = totalWidth / 2;
height = totalHeight / 2;

The variables width and height are initialized to zero despite immediately being set with new values on subsequent lines.  Although this code functions correctly, it lacks elegance and professional polish because the four lines could easily have been simplified into two:

int width = totalWidth / 2;
int height = totalHeight / 2;

The result is much more concise initialization for the two variables.

Exception: This rule does not mean you should try and cram as much information onto one line as you can – see the [basic.layout] rule for more information.

blog comments powered by Disqus