I've been thinking a lot lately on coding habits that I have been
picked up in recent years. Reasons I write in the way that I
do:
Code defensively. Other people will break stuff (and sometimes
the other people happens to be me...).
Think about merges. Code I write will go into a code repository
of some sort. Either I or someone else will need to do a merge at
some point. Make merges happen without issue.
Types! Types! Think thoroughly about problems of size.
Never use globals unless they are completely static (aka think
thread safe from the beginning)
So something I do not do:
int foo, bar;
I do this:
int foo; int bar;
Why? Because if I delete one of the lines, I then don't have to
worry about a bad merge. Any of the revision systems I use can
merge this stuff without a problem.
Other …