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.
Written by Richard Clifford
Related protips
Have a fresh tip? Share with Coderwall community!
PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.
Security insights from Cside