Category Archives: Uncategorized

How to write a book

Having completed the book Grails in Action with my co-author Glen Smith not so long ago, I thought it might be a good idea to post some of the things I’ve learned. Despite the title of the post, I definitely don’t profess to be an expert in this field – I’ve only co-written one book after all! The post also targets technical books, rather than books in general. Budding authors may nonetheless find some useful information here.

So, you’ve decided to write a book. What should your first steps be? Good preparation can make the writing process a lot easier in the long run, so we’ll start with that.

1. Write a sample chapter/half-chapter

Ouch. Is he serious? Yep. I suspect the last thing anyone wants to do before writing a book is to write an extra throw-away chapter, or even half a one. There is reason in this madness though.

It’s important to know how long it’s likely to take to write the book. That will enable you to schedule achievable milestones. Unachievable milestones are a great way to become depressed very quickly. It’s also a good idea to find out whether you enjoy writing enough to create a whole book. Better to find out now, rather than half-way through. That said, if I’d tried this, I may never have agreed to do Grails in Action!

If you’re sure you want go through with this, you’ll need to make some important decisions early on. Those decisions depend on knowing who your target audience is.

2. What background will your readers have?

Are they beginner, intermediate, or experienced developers? Will they have some knowledge of your chosen topic? Maybe they know a lot about a related topic, but not the one you are covering. The answer will have a profound impact on the style and content of your book, so think carefully on this one. Once you make the decision and have started writing, stick to it. Beginners will require more background information and more explanation for any given topic.

For example, with Grails in Action we decided to target intermediate to experienced Java developers who may know nothing about Groovy or Grails. We also wanted to fit as much advanced stuff and practical advice in as possible so that experienced Grails developers could benefit.

3. How big will your book be?

This may seem an odd question, but it’s closely related to another: how much stuff do you want to cover? The problem is, if you just think about what information you want to include, you may end up with a mammoth book that’s only suitable for weight lifting! Size is important. Some people like to carry books around with them. Others are intimidated by thick books that look impenetrable. On the other hand, some will view a thin book as light on content.

The overall page count can be estimated by the amount of information you want to convey divided by the pace at which you cover that information. The pace partly comes from writing style, but it is mainly determined by your target audience. A beginner’s book will inevitably have a slower pace than one targetted at experts. So, the faster the pace, the more information you can fit into a given number of pages.

4. Decide what you want to put in the book

By this stage, you should have an idea of how much you can fit into your book, so it’s time to look at what information you want to include. There will be trade-offs, have no doubt. The question is whether you go for more in-depth coverage of fewer topics, or lighter coverage of more. Or in-depth coverage of more topics and let the size of the book increase. Just be careful: you’ll probably find that topics require more pages than you expect. I certainly did.

This seems like a pretty big decision to make and hold yourself to before the book has even started. There is some leeway for sure, but sticking closely to your initial targets will help you keep the book focused. The publisher will be happy too, since they don’t have to make any last minute changes with the printers.

5. Organise your chapters up-front

This is almost a no-brainer. The chapter structure is the equivalent of the 60,000ft view of your book. You have to have some idea of what you want to say and in what order. You don’t have to stick to your initial chapter structure come hell or high water, but changing it will likely have a significant impact on chapters you have already written, particularly with regard to chapter references. You might also need to change examples and the like.

6. Pick an approach for sample code

There are basically two approaches to sample code: use a single example throughout the book that you build up; or use different examples in each chapter. You can even mix and match if you want. A single application running through the book seems the more popular approach at the moment, and it’s the one we chose for Grails in Action.

A single example provides a strong thread for the reader to follow and allows for continuity. It is also more likely to result in real-world code – something that readers appreciate. The main downside is that your chosen example may not suit all topics, and you may end up adding contrived functionality to demonstrate stuff. Using different examples gives you flexibility and the opportunity to use more appropriate scenarios, but each new example typically requires a bunch of support code too.

Now you’re ready to do some writing.

7. Start at the beginning

Writing your chapters sequentially will help you maintain a narrative. If you write them out of order, you won’t know what’s gone before and it becomes difficult to keep a sense of progression going. Remember that readers will typically read non-reference books from the start to the end, so that progression is important. For reference books, it probably doesn’t matter too much in what order you write the chapters.

One variation on this is to pick a chapter that you expect to be easy for your first one. That will help you get warmed up and into the swing of things before you have to tackle trickier topics. But I recommend returning to the sequential approach after that first one.

8. Use free writing

When you want to start a writing session, begin with half an hour or so of free writing. This involves just writing down anything that comes into your head, generally without any regard to punctuation or structure. Just write. This will warm you up and get you into writing mode. You can then use any bits of the free writing in your chapter if you want, but you don’t have to. Note that it’s not essential that you write about the topic that’s planned for the session, but it helps.

9. Use mind maps for each chapter

Mind maps are great tools for organising your thoughts and working out what should go in a chapter. You only have to do this once per chapter, but it’s probably best done after a free writing session on the chapter topic(s). Once you have a mind map, it’s worth turning that into a structure of sections and sub-sections, i.e. giving it a semblance of order. Sorting out the chapter progression in advance like this can make the actual writing much easier. You basically know where you want to go with the chapter, so the writing should flow naturally.

10. Keep communication channels open between co-authors

This may sound like a case of stating the bleeding obvious, but when you’re under time pressure and you just want to finish the chapters you own, it’s easy to skip reading your co-authors’ chapters and letting them know about changes to your own. You don’t want your book to end up with inconsistencies due to a lack of communication. As a concrete suggestion, make sure all co-authors read all the chapters before the book goes to production. It may take time, but it will save heartache later!

That’s it for now. If I think of any more advice, I’ll add it in later. Hopefully the above will help at least one poor soul who’s writing a book, or at least planning to.