|
Documentation-Driven Development
[
vmassol
]
I'm currently writing my third book and I'm starting to notice a pattern. Whenever I write a book about a tool/framework to which I have access to the sources, the code ends up being better. The way I work goes like this: I start writing about a topic. If it's taking too long to explain it, I consider that something is wrong about the code. I modify the source code so that the document I'm writing has the minimal required size to explain the topic. The good thing with a book is that what you're explaining has to be simple and not convulted which leads to this nice effect of improving usability of your code. I get a bit of the same result when I write project documentation but not to the same level. This is probably simply because writing a book is a more involved process, you dedicate more time to it and thus you want it to be as perfect as possible (and thus as readable as possible). I guess nothing here is new. This is all about having a user of your code. Tests are "users" of your code and thus leads to better design. I guess documentation can also be a "user" of the code and thus help improving it. If you're writing some framework/tool, consider writing a book for it and if you're diligent in your writing your code will end up being better! As an added benefit your users will love you... :-) TrackBackI think this can be applied to code reviews. We tried something like that. --Michael Slattery, January 21, 2006 02:19 PM
Perhaps not writing a book first, perhaps looking back a "literate-programming"... The point is that a "good" implementation is very often far away in its logic from natural speech anf the underlying thinking. When I write documentation I usually refactor code as I figure out an understanding that hadn't been obvious before, it goes thus in both directions: The real-world code teaches me something about the logic that hadn't been clear when designing the program. We made recently a small project where we wrote the documentation as the implementation advanced. We refactored both on different levels and ideas from a better understanding went back into the system. It was quite a fun to work like this (we didn't do this intentionally, originally we had to waste some time in a useful manner until the next specs drippled in). Now I finally understand the idea behind literate programming.... --Carsten Saager, January 21, 2006 06:22 PM
When answering questions on mailing lists about 'how do I do X with Y', I often find myself embarrassed about how complicated an answer can be. It's at that point I find myself committing some patches as it's far simpler to fix the problem, than to explain it. --Joe Walnes, January 22, 2006 06:18 PM
It reminds me the proposal of Laurent C : "When you create an API, before implementing it, write the tutorial explaining how to use it." Yet today, it's not a wide spread habit. Not only the quality of the API suffers from it, but better the people who would like to evaluate the API and/or the programming model, more early and easily. Well, you see my point: i'm evaluating a library currently in development, and there isn't any tutorial... :-) --Doj, February 1, 2006 01:26 PM
Vincent, if you really want to make a good documentation, is a paper book the best solution ? Do you never say to you: it is too much work, or there is a too big Overhead ? The Overhead comes from the fact that you have certainly an interesting subject, important maybe also, but the paper book you are preparing has to a nice history, nice and easy, or you will not be read. Mabe you could give also an hyperlink version, that will let Reader make their own navigation more in line with the interest he has on the different parts or with the Time he has. Again, Bon courage ! On the other hand I really understand that your approach gives a superior quality of your document and of your framework in the same time. --msa, February 1, 2006 10:36 PM
I've come to the same conclusion lately, from trying to reuse code from open source projects in my own project. In terms of reusability, code without an explanation is worse than useless because it can eat up your time trying to find out if it does what you need. I'm a satisfied user of many OSS projects, but I'd like to also re-use them, as a developer. --Keith, February 22, 2006 11:40 AM
I've written a tool, JCite, which supports this idea nicely. It lets you integrate snippets of code as examples in your docs, _cited from actual use-case tests_. That way, you ensure the integrity of the sample code. Also, I am thinking of a "tripwire" system that will flag docs citing tests which have changed. This will alert you to review the surrounding docs. http://arrenbrecht.ch/jcite/ --Peter Arrenbrecht, November 24, 2006 07:50 AM
Post a comment
|