A simple habit that made me a better developer. Writing the test before fixing the bug. I used to fix bugs first, then write tests after. Sometimes I skipped the test entirely. Now I do it differently: 1. Find the bug. 2. Write a test that fails because of the bug. 3. Fix the bug. 4. Watch the test pass. Why this works: You prove the bug exists before touching code. You prove the fix actually works. You prevent the same bug from coming back. One small change in order. Big improvement in code quality. Takes 5 extra minutes. Saves hours of rework later. What habit improved your code quality? #Java #Programming #Testing #SoftwareDevelopment #CodeQuality
This is a great habit, especially for early-career developers. Writing a failing test first makes the problem much clearer and gives confidence that the fix actually works. I used to skip tests too, but once you see how they prevent bugs from coming back, it completely changes how you approach coding. Small habit, big impact.
I have used TDD for implementing features, but I guess it's even more important for bug fixes.
Writing tests before fixing bugs sounds obvious but so many people skip it. What testing habits have helped you?