Test your code by little pieces - write a little piece and test it. It makes easier to prevent "brain crashes" and guarantees that you're working from a stable code base. This means that you have bugs that are isolated to only the code you've recently been working on.