Skip to content

Commit 1cfee17

Browse files
committed
Add table of contents
1 parent aa9c9f1 commit 1cfee17

1 file changed

Lines changed: 52 additions & 11 deletions

File tree

README.md

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,53 @@
22

33
### Thoughts on good API design
44

5-
The aim of this text is to explore API design and try to find
6-
strategies and rules that can help us create code libraries
7-
that are safe, efficient and easy to use.
8-
95
![go](res/go.jpg)
106

117
*Image from [Pixabay][pixabay], [CC0 1.0][CC0].*
128

9+
# Table of contents
10+
11+
[Introduction](#introduction)
12+
13+
[The 5 Commandments](#the-5-commandments)
14+
15+
1. [Tell me what this thing is](#1-tell-me-what-this-thing-is)
16+
2. [Tell me what it does](#2-tell-me-what-it-does)
17+
3. [Don't tell me how it works](#3-don-t-tell-me-how-it-works)
18+
4. [Grant me the right to use it](#4-grant-me-the-right-to-use-it)
19+
5. [Don't change it](#5-don-t-change-it)
20+
21+
[Keep it simple](#keep-it-simple)
22+
23+
* [Don't use complicated constructs where simple ones will do](#don-t-use-complicated-constructs-where-simple-ones-will-do)
24+
* [Don't use a lot where a little will do](#don-t-use-a-lot-where-a-little-will-do)
25+
* [One package, one idea](#one-package-one-idea)
26+
* [Just say no](#just-say-no)
27+
* [Math is simple](#math-is-simple)
28+
29+
[Give it time](#give-it-time)
30+
31+
* [Eat your own dog food](#eat-your-own-dog-food)
32+
33+
[Show, don't tell](#show-don-t-tell)
34+
35+
* [Create tutorials](#create-tutorials)
36+
* [Use examples](#use-examples)
37+
38+
[Tools of the trade](#tools-of-the-trade)
39+
40+
* [Keep it consistent](#keep-it-consistent)
41+
* [Write functions that need little and give much](#write-functions-that-need-little-and-give-much)
42+
* [Find a fitting interface](#find-a-fitting-interface)
43+
* [Make it generic](#make-it-generic)
44+
45+
46+
### Introduction
47+
48+
The aim of this text is to explore API design and try to find
49+
strategies and rules that can help us create code libraries
50+
that are safe, efficient and easy to use.
51+
1352
Many examples are in [Go][go], the language itself being
1453
a case study of good API design, with clean and simple
1554
interfaces on top of a huge complex implementation.
@@ -224,6 +263,10 @@ the Go project gets it right.
224263

225264
# Keep it simple
226265

266+
![scissors](res/scissors.png)
267+
268+
*Image by [ZooFari][ZF], [CC BY 3.0][CCBY3].*
269+
227270
Even though API design often requires us to make difficult trade-offs,
228271
a simpler API is almost always a better API.
229272

@@ -307,10 +350,6 @@ fleeting memory technologies.
307350

308351
### One package, one idea
309352

310-
![scissors](res/scissors.png)
311-
312-
*Image by [ZooFari][ZF], [CC BY 3.0][CCBY3].*
313-
314353
Chances are that you have never used the Java `Vector` class.
315354
It was superseded by `ArrayList` already in Java 1.2.
316355
The problem with `Vector` is that it does **two things**:
@@ -393,6 +432,8 @@ types of tasks and projects. Don't rush it.
393432
*Painting by [William-Adolphe Bouguereau][wab], 1865, public domain.*
394433

395434

435+
### Eat your own dog food
436+
396437
![Lorne Greene](res/greene.jpg)
397438

398439
**Eat your own dog food**
@@ -419,21 +460,21 @@ Tutorials, examples and quick start guides are great tools for
419460
improving an API. The goal is to make it effortless to get started
420461
and easy to perform common tasks.
421462

422-
### Tutorials
463+
### Create tutorials
423464

424465
[A Tour of Go][gotour] is a nice example of both a quick start and
425466
a tutorial. It's an interactive online tutorial that let's you try
426467
Go programming inside your browser without installing any software.
427468

428-
### Examples
469+
### Use examples
429470

430471
An example can demonstrate how an API is best used and
431472
help clarify subtle points. This [Bloom filter example][bloomexample]
432473
illustrates a typical Bloom filter use case, and it also helps clarify
433474
the tricky semantics of a Bloom filter probabilistic membership test.
434475

435476
Once in a while, an example can fully replace a more standard API element.
436-
Take a look this [DFS example][graphdfs], which shows how to implement
477+
Take a look this [DFS implementation example][graphdfs], which shows how to implement
437478
a depth-first search. Implementing DFS as a function with callbacks is
438479
really messy. There are at least four different points in the code where
439480
you may want to insert actions. Let's face it, occasionally cut and paste

0 commit comments

Comments
 (0)