In my previous post, I provided some tips about how to get started writing. That’s all well and good, but you would probably also appreciate some tips on what to write and how to organize your writing into something coherent and readable. Let’s dig into that now.
Many of us were taught a five-paragraph mode of construction: tell us what you’re going to tell us, tell us, the tell us what you told us. This is boring, repetitive and evil. Don’t do it.
Instead, consider this structure for your writing:
- Next steps
It’s similar to the old five-paragraph model — there’s an introduction, a body and a conclusion — but I think this structure better directs the organization of your writing and makes for more interesting reading.
The problem statement
The problem statement is the introduction. It serves two purposes. First, it explains briefly what your article is about. Second, it’s your opportunity to grab the reader’s attention.
Starting with the second point, many readers think being outrageous or funny makes for a good hook. While that can work, it throws an unnecessary variable into the equation. Are you really funny? Is that enough to hook a reader? Are you sure?
Maybe it’s better to just clearly state what you’re writing about. Provide some context: what does it relate to (language, platform, type of development…), and why should I care (am I doing it wrong, does this make my code faster, stronger, less buggy…)? This is why I called it a “problem statement.”
Readers are often more interested when you clearly define your subject within a the scope of a problem they might encounter and one or more solutions that solve the problem. One approach, of course, is to literally solve a problem, but taking a more abstract view of the problem-solution structure can help guide your writing on other topics as well.
Keep your introduction brief, but it can be several paragraphs if necessary to set up the context in sufficient detail. However, make sure at least one paragraph — preferably the first of last paragraph of your introduction — clearly states what your entire post is about. People who will share your article in social media, aggregators and newsletters will cut and paste. Make it easy for them.
View controllers are often the biggest files in iOS projects, and they often contain way more code than necessary. Almost always, view controllers are the least reusable part of the code. We will look at techniques to slim down your view controllers, make code reusable, and move code to more appropriate places.
Notice that, in three sentences, Chris explains the context (view controllers in iOS programming), the problem (they’re too big and not reusable) and what he’s going to explain (a solution for slimmer, more reusable view controllers).
High school geometry comes in two distinct flavors: Euclidean geometry is oriented around constructions, theorems and proofs, while analytic geometry describes geometric figures numerically using points on a coordinate system, often called the Cartesian coordinate system in honor of the pioneer of analytic geometry, René Descartes…
In the previous installment of this column… I discussed how to use the ID2D1PathGeometry to render lines in a finger-painting application that runs under Windows 8. Now I’d like to step back and explore geometries in broader detail, and in particular investigate some of the intriguing methods defined by ID2D1Geometry for manipulating geometries to make different geometries.
This is a longer introduction, and I’ve even left out a paragraph for clarity, but you can see that it includes the same building blocks: a context (geometry in Windows 8 programming, continuing from a previous articles), a problem (geometry is hard, you need to know how it works) and a solution (learn about ID2D1Geometry).
If you can keep your introduction — your problem statement — focused like this, it will help you keep the rest of your article focused as well.
This is the meat of your article and where you’ll spend the most time writing. I won’t spend too much time on this as it’s really the focus of my first post on getting started writing. You just need to pick a subject and start writing.
The main portion of the article is where you can explain the problem or opportunity in more depth than a concise intro problem statement allows. Stop and provide some more context if necessary, though don’t let it distract from getting to the solution. If the problem starts to become the entire article, you might want to rethink what the article is about. Maybe that’s another writing project altogether, or maybe you can link to more context elsewhere.
How you write about your “solution” depends on subject and the way you want to organize your ideas. A few common patterns are:
- Start from the beginning and work through to solving the problem
- Pick a few key elements to explain
- Top ten lists (pro tip: odd numbers work better)
- Analysis of different patterns or implementation approaches
- Pros and cons
There’s not necessarily a right or wrong way to organize the core of your writing. Go with your gut, pick something and run with it. After you complete a draft, if the organizing theme you’ve selected doesn’t seem to be working, don’t try to force it. Rather, be open to refactoring and heading in a different direction. Reorganizing takes less effort than re-writing.
I’m of the opinion that a blog post or article does not, in fact, require a formal conclusion. If you finish your subject and want to simply stop, that’s fine.
This is particularly true of very short blog posts that cover a single, very focused subject. Provide some context and a problem statement, explain yourself through your solution, and done!
If you do want to provide some closure, don’t simply restate your original thesis. Instead, you can just sum up quickly: “That’s a quick overview of recursive dohickies in action.”
Another approach, if there are other considerations, is to qualify your solution. Although I’ve warned against pedantic, edge-case addicted readers, you don’t need to be all-inclusive or all-encompassing in your solution. Just explain that there’s more to the subject: “This solution works well for most apps, but edge cases X, Y and Z require additional hemming and hawing.” Maybe that’s fodder for future writing.
As implied by my heading, it’s always helpful to suggest some next steps for the reader: Where to learn more or find additional examples. Other potential solutions or associated technologies. Ideas for further or more sophisticated implementations. You don’t need to go on at length. A simple mention and, perhaps, a link, goes a long way.
Use links to your advantage
Links are the lifeblood of the web, and links in your article are good. They let you pull related context and information into your post without having to write it. They also let you recommend quality sources of information and code to your readers, situating your own writing within the larger web of discussion on the subject.
You can (and should) link to your own previous posts. Go back and add links in previous posts if you cover the subject again later. This is particularly important for multi-part series of articles so a reader can find the beginning of the series from any post in the series, then follow through from the end of one post to the beginning of the next. If you make it easy for readers to stay on your site, they will.
Link to other people’s posts if they’re relevant and helpful. People (readers and writers) appreciate that, and if they’ve already covered a subject, it saves you from repeating it.
Link to apps, libraries, reference material and anything else that you use or discuss in depth so readers can find and use it too. Make sure you get the name right, though, and it’s a nice touch if you check occasionally that links still work.
Comments on the code examples
Code is great. You should definitely include code examples if they’re relevant to in your writing. But a code example does not replace an explanation.
If you show code, you should explain the code, even if it seems obvious to you. You wrote it. Of course it’s obvious. However, your reader is trying to learn. If it was obvious, they wouldn’t be reading… and many of your readers are going to be far less accomplished programmers than you. Help them understand.
In fact, this is where a lot of official documentation falls down. It shows the most basic example, but never take it farther than that. Then it jumps straight to a complete sample app. There’s often little explanation of how you get from A to Z.
And as we know, the API is rarely as straightforward to use as the author thinks. There are always inconsistencies and gotchas and misnamed features and things that look the same but do something completely different.
You don’t need to show all of your code if it’s available somewhere else. Just the important or interesting bits, and a link to peruse the rest.
If there are dependencies, make them clear.
Test your code in a fresh environment (VM maybe) to double-check that there are no unexpected dependencies. “It works on my machine… ” is never a good excuse.
The specific coding style choices you make are not as important as consistency and clarity. Pick something and keep with it. It can help to use super-clear naming that you might not use in real code.
More on writing about code
This is part of a series of posts discussing the main points of my “Writing About Code” presentation at Vermont Code Camp 2013. Here are all of the posts in the series:
Now, get writing…
Writing code is job one for most software developers, but learning to write about code is almost as important. Whether you’re documenting an API or showing off your own smarts, when you set out to write about what you think you know, it tests how well you really know the subject. As you write, you’ll often end up deepening your understanding of how the code works and honing your skills as a developer.
In this post I’m going to provide some tips and tricks for programmers who haven’t done much writing that will help you get started and find early success that fuels more writing.
This is a distillation of the first part of my “Writing About Code” presentation at Vermont Code Camp 2013. I don’t believe dumping my slides on the web helps. Instead, I’m pulling the most important ideas from my presentation into a few blog posts that are easier to read, digest and use to fuel your own work.
Why write about code?
There are many reasons to write about code. Maybe you want to share your knowledge and enthusiasm for programming, to market a product or teach customers how to use it, to promote your own abilities or because it is (or should be) part your job.
But I’d like to suggest another, more valuable reason, best summed up in this ancient wisdom from Seneca the Younger: Docendo discimus (“by teaching, we learn”).
Whether you write for yourself or decide to write publicly, you’ll start to explain something and, often as not, start wondering: Really? Is that all there is to it? What am I missing? How does this work? Engineers — your target audience — are always going to point out edge cases and pedantic details. Are you ready?
Go ahead and second guess your assumptions about your code, dig into the how and the why. You will most likely learn something new and improve your skill as a developer.
My code speaks for itself, right?
Unfortunately, your code does not speak effectively for itself — not for a wide audience anyway.
A code example does not replace an explanation. Sure, there are times when sharing a simple code snippet seems sufficient, but even then it’s usually posted in the context of a discussion… usually via social media.
If you show code you should explain the code, even if it seems obvious to you. You wrote it, so of course it’s obvious. But there are many other people — your potential readers — who are trying to learn. If the concepts you present in your code were obvious, these people wouldn’t need to be reading about it.
Many of your readers are going to be far less accomplished programmers. Believe it or not, by simply taking the time to research and write a blog post, you become an expert. Help them understand.
In fact, this is where a lot of official documentation falls down. It shows the most basic example, but frequently fails to take it farther than that. Then it expects you to jump straight to a complete sample app. There’s often little explanation of how you get from A to Z.
You may think it’s all be written before. What do you have to contribute? We’re still figuring this programming thing out. Every bit of knowledge helps move the profession forward. People are still writing about C. People are still writing about Cobol! Your unique approach to the subject may be the key that unlocks a problem for some reader.
Fear of writing… or how I learned to stop worrying and just write
The most important tip: Write something. Anything. Just get it out of your head and on the screen. Make time to write every day. 100 words or 30 minutes or whatever seems achievable on a regular schedule. As you become more comfortable, try increasing your target time or word count.
Do make it a habit, but don’t make it a chore. If you get stuck, stop and come back to it later.
Use the tools and languages you use every day. Write about the thing on your mind right now. A distraction that often gets in the way of writing (and probably coding, too) is obsessing over the “best” tools. There is not best writing tool, and messing with different editors just keeps you from writing. Word is fine, but so is a basic text editor… your IDE will probably work fine if that’s where you’re most comfortable and productive.
Don’t underestimate the usefulness of pencil and paper.
A helpful approach for avoiding editorial paralysis is to commit yourself to at least two trips through the material. I think most people get in trouble by trying to edit while they write. The result is usually not writing. An outline or a list of the major points you want to touch on works well, but from that starting point, try to write stream-of-consciousness. Get as much down on paper as possible.
Don’t fixate on the entire article. Work idea by idea, section by section. Each sentence is a building block for a paragraph, and each paragraph is a building block for your article.
Although correct technical details are important, as are correct spelling and capitalization, don’t get hung up on researching each topic as you write. If there’s something I’m not sure about or that needs more detail, I prefer to make a note to myself inline to go back and double-check or add more information later. Better to have the sketched out skeleton of your writing in place rather than getting side-tracked by research from writing at all.
Write a complete first draft before making any edits or revisions. That includes fretting about spelling, grammar, and so on. Once that draft is complete, then read it through, fix mistakes, add details, re-order, refine, and refactor as needed.
Focusing your big ideas into byte-sized pieces
A common problem for writers is determining the scope of what you’re going to write about. If the idea is too big, you’re likely to run into two problems: You either never finish (which is frustrating) or you skip over important details to finish (which leads to a poor finished product).
At least when you’re starting out, focusing your writing on small, achievable goals will help you succeed more often, giving you confidence in your writing and setting up a positive feedback loop of writing, accomplishment and more writing.
It’s often better to focus in on a very specific detail and write about that as clearly as possible. You have a more clear goal for the writing in front of you. You can often think around the smaller concepts more easily. Plus, there’s less to write — you’ll finish more quickly.
You can stitch together other small, focused bits of writing into episodic blog posts (Oren Eini does this very effectively on his blog) or into a longer article.
You’ll often find that small topics aren’t really so small when you dig into them. Think about not just how you implement a solution, but how it works… and why. What are the edge cases? What’s helpful to know? How much is boilerplate, implemented for you by the IDE or framework? Can you explain how that all works? How much is “received wisdom” about how things should be done, or code IntelliSensed in with a keystroke?
In fact, I suggest, as an exercise to practice writing about your code: take a chunk of code and explain it block by block. I bet you’ll discover quite a few assumptions you’ve made along the way. It doesn’t have to be your code. Document some random source code just for the practice.
Avoid pasting in large code blocks. It hinders the flow of reading and distracts your reader while she deciphers the entire block. Instead, break your code into digestible snippets if at all possible. Explain each bit as you go through. At the end you can provide the entire code block for copying and pasting, or link to a file/repo.
I suggested digging into the details, but you don’t always have to explain how deep the rabbit-hole goes. Most of the time, unless you’re writing basic programming tutorials, you shouldn’t have to explain how a for loop works, or what you’re iterating or basics like that.
Instead, think about the conceptual building blocks of your idea. Break code down into snippets that let you discuss it in terms of those building blocks. For nuts and bolts coding, that may mean discussing code line by line within individual methods. Other times you might discuss the overall construction of an entire class (suitably simplified, if possible) or of classes within an application.
As an example, take a look at Chris Eidhof’s Lighter View Controllers article at objc.io, which examines code organization at the class and file level. Then consider Peteris Krumins’ Bash One-Liners Explained series of posts, which by definition examines one line of code at a time in great detail.
What to write about?
Still not sure where to start? Here are a few ideas:
- Write about what you’re enthusiastic about
- Write about what you’re curious about
- Write about what you’ve done that makes you feel smart
- Write about a problem you had to solve
- Write about what annoys you or makes you smile
- Write about what you don’t understand: you’ll learn along the way
There is a audience out there eager to learn. Start writing for them. It will do you some good, too.
People love to learn how things work… and why.
People love when someone else solves their problems.
People want to know what they need to know and where to find it. They want to know how to get started, and then they need to be handheld from the simple to the more complex.
People always appreciate clever and useful utilities and code snippets, and tips for how to use them.
Stop reading, start writing
You have some basic tools for getting started. Now put them to work and get started writing something every day. You don’t have to publish it. Just keep a journal for practice… a journal of ideas, which you might return to later for material as you become more confident in your writing.
This is part of a series of posts discussing the main points of my “Writing About Code” presentation at Vermont Code Camp 2013. Here are all of the posts in the series:
Now, get writing…