I learned early on as a junior developer to be paranoid when it came time to code the design. There are a few rules that I learned to keep in mind that have allowed me to pass more unit and system tests.
One, don't trust the data that comes into your method/function/subroutine.
Two, don't trust the data that comes back from methods/functions/subroutines that you call.
Three, assume that other users will not trust the data that you modify and/or return from the function/method/subroutine that you're writing, and therefore accurately report to them anything that goes wrong.
I've noticed a trend in the past few years in younger developers, that they tend to develop with the best case scenarios in mind, believe that users will always enter valid data, that functions are always correctly documented and always require and return exactly what their documentation states, and that therefore the developers' code will never break unexpectedly. There is the idea that error checking isn't needed anymore because it's a waste of effort and time, that Java will always throw exceptions when something really bad happens, and rebooting/restarting the software will fix everything. I have to tell them that Java can't report failures caused by violating the business rules behind the design, that it's important to check for valid data and valid execution.
Of course, since I'm old and "unable to keep up" I'm now working maintenance on a big system, but I've found several show-stopper bugs that would not have shown up had the developers been just a bit more paranoid in the design stage. It would also have been cheaper to find the bugs before deployment, but the testing staff is overworked and understaffed, and stuff gets through, and so we have to get the trouble tickets from senior management in the customer's organization (USGov) when critical things break. People who when they are unhappy enough, take contracts away from the developers who make them unhappy.