I have found that I can reduce (not eliminate) the need to debug my functions in this way by using unit tests as part of a more test driven approach.
Mathematica supports test driven approaches using a "Testing Notebook" under:
File | New | Programmatic Notebook
If you would rather keep your unit tests closer to your code, you can include VerificationTest
In addition to unit tests, I also find asserts and checks useful.
Thanks for the great question.