Code Caveats

Test-Driven Development with Inversion of Control.

Even if you aren’t testing your code, you should write testable code. IoC enables testable code. Inject test-friendly dependencies or mocks at test time, to isolate the unit-under-test.

Avoid mixing Object Creation with Application Logic

Source

Avoid Code Smells

Source

Avoid creating technical debt.

“Although immature code may work fine and be completely acceptable to the customer, excess quantities will make a program unmasterable, leading to extreme specialization of programmers and finally an inflexible product. … A little debt speeds development so long as it is paid back promptly with a rewrite … Every minute spent on not-quite-right code counts as interest on that debt. Entire engineering organizations can be brought to a stand-still under the debt load of an unconsolidated implementation …” (Emphasis mine)

Source

Premature optimisation is the root of all evil

“Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.”

Source