Examples Of Bad Code #25643

I’m sure you’ve all seen this one. Rather than having code looking like:

result = functionCall(foo, true, false, false, true, true);

some bright spark thinks it’d be a great idea to replace the boolean parameters with something more “human-readable”. So, they #define a whole heap of macros and instead they call:

result = functionCall(foo, MACRO_ARG_MEANING_TRUE, MACRO_ARG_MEANING_FALSE, MACRO_ARG_MEANING_FALSE, MACRO_ARG_MEANING_TRUE, MACRO_ARG_MEANING_TRUE);

And then they feel happy that their code is more “understandable”.

No No No No! The problem is in the tool, not the code. If you don’t have a decent editor that allows you to quickly cross-reference across your codebase then get one.

Stop making the code look like a dog’s dinner because you have a bad editor.

Comments are closed.