In: Computer Science
Describe defense in depth.
I will explain defense in context of programming. Hope I have understood your question well.
Defensive programming is a mindset to write your code in such a way that it is hard to use it not in the original intention of the code. In simpler terms, it prevents malicious use of the code.
For example, in OOP, you don't want to return a (non-const) reference to your member variable because if you do, anyone could change the state of the object and most likely, this is not what your original intention is.
Another example: When you want to access element in an array, you will check if the index is a valid one (i.e. -1 < index < size of array) before you actually making a call to access the element.
Without defensive programming, your code will still run under normal condition/input but it is really easy to break it or make it to do something that's not intended to happen in the first place.