Whether you're writing a book, code, or a school essay, I really recommend visually planning out your thoughts.
The problem with pen and paper is that correcting and re-arranging your ideas gets messy, and defeats the original idea.
There are many software tools to do mindmapping, and honestly, the few that I've tried have been more of a pain than a help.
I recentl found mindmup. I love it! And recommend it. It's free. Open source. Works with Google Docs seamlessly. Exports useful formats like PNG and PDF.
And more to the point, it is really friction free. For me it has been the best tool, just stays out of the way like a good tool should.