Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!


Forgot your password?

Writing Documentation: Teach, Don't Tell 211

Programmer Steve Losh has written a lengthy explanation of what separates good documentation from bad, and how to go about planning and writing documentation that will actually help people. His overarching point is that documentation should be used to teach, not to dump excessive amounts of unstructured information onto a user. Losh takes many of the common documentation tropes — "read the source," "look at the tests," "read the docstrings" — and makes analogies with learning everyday skills to show how silly they can be. "This is your driving teacher, Ms. Smith. ... If you have any questions about a part of the car while you’re driving, you can ask her and she’ll tell you all about that piece. Here are the keys, good luck!" He has a similar opinion of API strings: "API documentation is like the user’s manual of a car. When something goes wrong and you need to replace a tire it’s a godsend. But if you’re learning to drive it’s not going to help you because people don’t learn by reading alphabetized lists of disconnected information." Losh's advice for wikis is simple and straightforward: "They are bad and terrible. Do not use them."
This discussion has been archived. No new comments can be posted.

Writing Documentation: Teach, Don't Tell

Comments Filter:
  • Stack Overflow (Score:4, Informative)

    by EMB Numbers ( 934125 ) on Tuesday September 03, 2013 @07:13PM (#44751773)

    In my opinion, Stack Overflow is most often the blind leading the blind. There will be 20 wrong answers, 10 answers to the wrong question, 2 suboptimal solutions, and if you are in luck there will be 1 good solution. Now, tell me which is which. It seems to me that the good answer is almost always buried under crap.

    Stack overflow questions are often badly stated and difficult to find with more correct search terms. If you don't even know the search terms, the site is useless.

    There have been a few times when stack overflow saved me a lot of time. There have been many times when stack overflow has been a pointless time sink.

  • Re:Source code (Score:5, Informative)

    by Anonymous Coward on Tuesday September 03, 2013 @07:35PM (#44751919)

    I hate you! You're one of those co-workers that urgently e-mails me at 1AM in the morning asking me how to use some utility I wrote. In the morning I reply, "Use the -h switch, you mother f*cker." Followed by my usual disclaimer--"Every utility I write has an -h switch, which describes the switches option-by-option, followed by short description of the function of the utility, plus gives links to additional documentation."

    And if you think you're going to find the -p switch in OpenSSH source code, good luck. Option argument handling is strewn about in several different files. I know, because I've had to hack on it and add options, as well as fix the parsing of forwarding option arguments, among other things. I've seen worse, but it's a long way from some utilities, where getopt and getopt_long processing is concise and easily readable.

    Pro tip: readable source code has nothing to do with methods, classes, functions, or variables per se. It's the overall structure that counts, even if it's a single 10,000 SLoC function. Most C++ apps are harder to read than a gigantic ASM app.

    Most people organize their code by what it literally does--by the components they learned in school or a textbook. They tediously breakdown blocks into a myriad functions and classes based on their algorithmic role. Or they farm out "parse_int", but then have a 200-line chunk of code processing a dozen different kinds of ints (ints for timeouts, ints for userid, etc).

    I don't have many simple tips for alternatives. I just know that most people are doing it horribly wrong. I like to think my code is fairly easy to read--and people have told me that--but I know I could get better.

    Okay.. one simple thing people could do more often--use fewer source files, fewer classes, etc.

    Also, people abstract too early, before they understand what the meaningful abstractions are. So they end up with too many abstractions, creating too much complexity. People should begin to write their applications as quickly as possible, without worrying about structure--just functionality. It's only until you're about one third or even halfway through that you have an idea of how the whole application should be structured. That's when you start over, before it's too late to re-architect, but after you have a concrete idea of what's necessary and what's superfluous.

  • Re:Source code (Score:4, Informative)

    by snowraver1 ( 1052510 ) on Tuesday September 03, 2013 @07:49PM (#44752003)
    -h? Next time, use all three of these: -?, -help, --help. I'm probably not going to try throwing -h at a program without having a clue what it might do.
  • Re:Source code (Score:4, Informative)

    by lgw ( 121541 ) on Tuesday September 03, 2013 @07:53PM (#44752019) Journal

    Command line utilities should print their documentation for any unrecognized or erroneous command line arguments (unless that's so lengthy they need to only print a subset).

  • Re:Stack Overflow (Score:5, Informative)

    by real-modo ( 1460457 ) on Tuesday September 03, 2013 @08:16PM (#44752173)

    Well, I am going to defend Stack Overflow here, because I think it fills a very useful niche, which is "what is the best way to do X."

    closed as not constructive by XxxxxX Sep 29 '11 at 13:29

    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

The moon may be smaller than Earth, but it's further away.