24.
use coherent identifiers
Choose:
∙ One language:
I prefer English given keywords are English, but any will work!
12

25.
use coherent identifiers
Choose:
∙ One language:
I prefer English given keywords are English, but any will work!
∙ Use one variable style:
If you prefer use CamelCaseIdentifiers;
Or, why not, underscores_identifiers;
but not both!
12

26.
use coherent identifiers
Choose:
∙ One language:
I prefer English given keywords are English, but any will work!
∙ Use one variable style:
If you prefer use CamelCaseIdentifiers;
Or, why not, underscores_identifiers;
but not both!
∙ Note that some languages have conventions:
Java libraries use CamelCase;
GNU Toolkit (GTK+) use underscores;
So, probably a good idea to follow the ﬂow…
12

31.
be explicit
C, Java and C# are tolerant, so you can write
if (foo < bar)
do_something(foo, bar);
Look, m’a! No curly brackets!
16

32.
be explicit
C, Java and C# are tolerant, so you can write
if (foo < bar)
do_something(foo, bar);
Look, m’a! No curly brackets!
Problem? Later you might need to add an action and probably you
will add it like this:
if (foo < bar)
do_something(foo, bar);
do_something_else(foo, bar);
And does that do what you mean?
16

33.
be explicit ii
So, how do you read this?
if (a < b)
if (b < c)
a = c;
else
c = b;
Or, more important, how does the compiler read it?
17

37.
use proper data structures
Implement related data as a data structure.
So, in pacman we have four ghosts. Store their positions.
int g1x, g1y, g2x, g2y, g3x, g3y, g4x, g4y;
There are only four, right? And it works!
19

45.
documentation relevance
Documentation is like sex:
when it is good, it is very, very good;
and when it is bad, it is better than nothing.
— Dick Brandon (?)
24

46.
documentation content
Try to include:
∙ What the code is about;
∙ What are each of the input arguments/parameters;
∙ What is the type and content of the returned value;
∙ If any of the method/function parameters are for output;
∙ What restrictions does the input values have?
∙ What happens when you do not follow that restriction?
∙ What exceptions are thrown directy?
∙ What exceptions are not catched and might be propagated?
∙ What is the algorithm?
25