I used to start out with a general idea but almost no planning, but ever since I sold my first book and my editor asked for an outline for the next two (with the offer of a two-book deal possibly on the table I was definitely not going to refuse to do what she asked!) and I learned the value of planning, I started doing a lot of planning in advance, mostly just as a way to generate ideas. However, I have never felt the need to stick to the plan if better ideas come up during the writing (which they often do). As I write, I may change the plan often (or, again, I may not), or make up new plans as I go along and write them up so I don't forget them—nevertheless, those plans may or may not make it into the book either. Ultimately, somewhere close to the end, all the different ideas and plans begin to fall together, and I realize that none of it was wasted effort and it is all a vital part of my process.
And it is much the same with research: I do some in advance, but also do more, intermittently, as I write. The advance research inspires ideas, and the research as I go along helps me work out problems that have come up, or just gives me something useful to do during temporary blocks. I keep notes on my research because I know that even though some of the best bits may never make it into the current story or series, they very well might inspire something for a later story. So I never know when I am researching whether I am doing it for the book I am writing, or for something I may write in the future.