So - to make this thread about something rather than my personal revelation - how do you plan out the code of your projects? How comprehensive does the plan have to be before actually coding?
I plan about two or three 'steps' ahead at all times, and have a vague general idea of where I'm going. However, I write almost nothing down.
If I start a project from scratch, I might tackle graphics first, in which case I start thinking about how I'd like to organize sprites and resource managers, then I might think about how I would compose those to draw scenes, etc. I know what I want to end up in the end, but I don't start by sitting down and hammering out a bunch of UML diagrams, and I don't recommend you do either -- it's an enormous waste of time unless you're part of a large team and even then I suspect it is still a waste of time*.
The trick is to write code that is reasonably extensible and accept that if you are working on a reasonably-sized project you will probably end up having to do some refactoring one way or another (although obviously you should try to limit the time you spend doing this). Write simple code that does simple things, and work iteratively. Try to replace planning with good coding practices that minimize the amount of planning you really need to do.
The only documentation I maintain now is a list of features that still have to be implemented and a second list of fixes and updates to existing code. According to XCode Assistant, my project has grown to 31 000 lines of code, and my documentation is about twenty lines.
* Anecdote: when I was working for the man (not Batman), I was asked to design an optional module for our company's largest product. I drew up a shiny document that got passed around to managers and some of our larger clients. Everyone liked it so much I was asked to do a whole bunch of them for additional features and such. By the time I was writing document number three, the project from document number one had already basically been shelved due to time constraints. The purpose of most design documents is not to assist in implementation, it is to get clients excited so you can drum up business, or to make it look to your boss (who doesn't really understand what you do) like you're doing something that justifies paying you money.