Skip to main content

4 docs tagged with "Coding"

View All Tags

Always use a Brace

In C, C++, Java, and other languages, you use curley-braces — '\{' and '\}' — to indicate the start and the end of a block of code.  However, the braces are optional if the block is only a single line.  This is an option you should never use.  Always use the brace, even if it is a single line.

Avoid Deep Conditional Nesting

Simply put: try to make your conditions as flat as possible.  This makes them generally easier for the humans to parse and understand.

Code Only What You Need

Only commit to code that which needs to committed to code.  Only write what needs to be written.  How hard can that be?  You might be surprised, but there are developers out there that are so enamored with the code design that they implement entirely unnecessary things. The best of intentions is actually a waste when you implement something that is never actually used.

Null vs. Error?

You call a method to retrieve information about an object with a  particular ID, but the record does not exist.  Is this an exception?   Or not?  It is hard to answer.