Writing better software design documents
@clobrano@fosstodon.org asked:
How does anybody get good in writing software design docs? The more I try, the less I feel confident đ
To which I replied:
- Find and read good design docs.
- Ask people to provide feedback on the design docs you write.
- Search the web for checklists of topics to include.
- Add your own topics relevant to the area you work in.
- Work on your general writing skills, e.g. read âThe Elements of Styleâ by Strunk and White.
- If you understand an aspect of the design clearly, write it up so others can understand it too. If you don't understand an aspect, write down a question about it and try to find the answer.
What makes a good design document?
I think the most important purpose of a good design document is to define terms clearly and describe the mental model of how the software fits together. Capturing rationale and alternatives considered is like gold dust and a great gift to one's future self. (It's really hard to remember that kind of stuff years later.)
Writing introductory material and defining terms early on has the advantage that one's viewpoint is closer to that of a beginner. That doesn't last long! Also, it's only when you write something down that you realise you don't understand it quite as well as you thought.
Resisting the urge to start coding until you've got a reasonably clear understanding of what's needed not only saves time overall, but captures information useful to others.
Someone with no previous exposure to the piece of software should be able to understand the terminology and start to find their way around the code. The design doc might not get them immediately into the code, but they should be able to start browsing and searching the code and find some of the terms introduced in the design doc so they can begin to grok the code.
Generally, over the years my design docs have become shorter. I don't include detail which should be code or code comments as that will tend to go out of date quickly.
Topics to cover
The topics to cover in a design document vary, depending on the project, but here are some examples of the kinds of headings you might see:
- Requirements
- Scope
- Out of scope
- Architecture
- Interfaces
- Major dependencies
- Operating systems supported
- Hardware platforms supported
- Configuration
- Security
- Performance
- Compatibility
- Interoperabiity
- Internationalisation
- Alternatives considered
Don't design documents go out of date?
I think there's some value in keeping old architecture or design docs without necessarily keeping them up to date. The original rationale is valuable information and doesn't tend to go out of date. They just need to be treated as historical documents.
There is some value in capturing tests as a way of documenting the design that doesn't go out of date. Tests, at least partially, answer the question âWhat does this code do?â, but they don't necessarily help answer the question âWhy was this code written?â, something that a design document can describe and which will continue to remain true because it's a description of the past.
Example design documents
The following are some examples of hopefully good design documents. These are mostly from projects I've been directly involved in.
Each example links to the design document and provides a graphic to give a flavour of what's there.
If you know of excellent examples I could add, please let me know.
A note on Z specifications
Please note that some of the following design documents are Z specifications. These contain a mixture of English, which should be fairly readable on its own, and formal, mathematical models that describe the state and operations of parts of the system being modelled.
The Z specifications were intended for anyone with sufficient mathematics to follow them, but primarily for myself as an aid to understanding. Each Z specification includes an introduction to the Z notation as an appendix, which should be sufficient to give anyone with sufficient mathematics a reasonable clue as to what is going on.
1. Diagrams: Eclipse Virgo concepts
I wrote Virgo Concepts some years back. As well as introducing the main concepts behind the Virgo modular application server, the page serves as the introduction to some other design docs about Eclipse Virgo.
The page was intended to be read by (potential) contributors to Virgo.
2. Apache Tomcat 9 Architecture
The Apache Tomcat 9 Architecture site defines key terms in an overview and then describes server startup and request process flow using UML sequence diagrams.
3. Image Relocation: README
The design docs here consist of a README as well as some Z specifications (see below).
The README was intended for users of the image relocation library.
4. Image Relocation: formal specifications
I wrote these specs, in a mixture of English and the Z specification language, as a way of getting my head round Docker/OCI images and registries.
(Click here to enlarge.)
5. UML: jvmkill Developers' Guide
The jvmkill Developers' Guide included a sequence diagram to explain the interaction between the Java Virtual Machine and the jvmkill agent.
6. An Abstract Model of Linux Control Groups and Subsystems
Steve Powell and I wrote this formal specification of cgroups and subsystems when we were trying to understand those Linux features when preparing to work on the garden project.
Here's a snippet showing one of the Z schemas:
[ | about | blogroll | contact | now | search | subscribe | © | ]