Practice TDD, even on small projects, and write unit tests as you go
Learn how to use an IDE-integrated debugger properly
Avoid magic at all costs (the reflection-based DI in .NET is a particularly egregious example of this -- it is literally undebuggable)
If you have assumptions about how this should work, assert() that they are correct.