Last Updated: February 25, 2016
·
655
· darkmantiscs

Logic, Logic, Logic

This should be a given to most programmers but It's not to all

No matter what language you use, always, always, check the state of your variables and compare them with what you are expecting. If you presume that they are populated somewhere else without checking them, then you could have a mess on your hands that could be potentially very difficult to debug.

Always create enough logic to ensure that your variables are always the right data type, value and if you're dealing with arrays or objects (mainly in languages like PHP, Javascript, etc) then always do a count/sizeof on them to make sure that they are not empty and always check if the array key exists before trying to access it.

In conclusion:
Assuming will get you nowhere in programming.