I use a mixture of both discovery and planning. The problem with pure discovery approach is I sometimes start to code when I am not completely attentive because of deadlines, and if I am working with a larger codebase it is difficult to instantly start writing code because you need some time to understand the context. I always have a text file open all the time where I note down stuff such as: context, plans, ideas, edge cases, conflicts, todos etc.; it serves as a swap memory.