Why Good Systems Need Both Dependencies and Discipline
Hatched by Kai Nguyen
Jun 22, 2026
10 min read
1 views
72%
The hidden question behind order
What do graph algorithms and documentation rules have in common? At first glance, almost nothing. One belongs to the world of dependency resolution, the other to the world of readable prose. Yet both are really answering the same deeper question: how do we impose a useful order on things that do not naturally come in order?
That question appears everywhere. In software, tasks depend on other tasks. In writing, explanations depend on context. In teams, decisions depend on prior decisions, even when no one has written them down. The moment you try to make a system understandable, executable, or maintainable, you discover the same constraint: some things must come first, some things can only come after, and some things are only useful if they remain visibly connected to what they support.
A topological sort is a way of turning dependency into sequence. A good docstring is a way of turning dense intention into sequence. Both are methods for making hidden structure legible.
Order is not the opposite of complexity. Order is what complexity looks like when its dependencies are made visible.
The surprising insight is that these two practices, one algorithmic and one literary, share the same discipline. They both ask: what is the minimum structure needed so that another mind, or another machine, can proceed without guessing?
Topological sort is not about sorting, it is about respecting reality
The phrase “topological sort” sounds like a general way to arrange things neatly. It is actually much more specific. It only works when relationships are directional and acyclic, when one thing must happen before another, and no loop traps the system in mutual dependence.
That makes it a model of reality, not a mere programming trick. Build a house before installing the roof. Define a class before instantiating it. Compile a module after its imports are available. There is always a partial ordering, a structure that says: this can be earlier, that must be later, and some items are independent.
The key idea is not linearity, but constraint. Topological sort does not invent order from nothing. It reveals an order already implied by the dependencies. That is why it feels elegant. It respects what the graph already knows.
A useful way to think about it is this: a source is a point where work can begin because nothing is holding it up. A sink is a point where work can end because it depends on everything that comes before it. Most real systems have both. The art is to move from sources to sinks without pretending the path is arbitrary.
This has an important managerial and cognitive implication. When a project feels chaotic, the problem is often not too many tasks. The problem is that the dependencies are invisible, so people keep trying to do later work first. The result is frustration, rework, and false urgency. Topological thinking says: before asking “What should we do next?”, ask “What must be true for the next step to exist?”
Documentation is a topological problem in disguise
Good documentation faces the same challenge. A reader cannot absorb everything at once, because understanding itself has dependencies. Some information is obvious and can be compressed into a one-liner. Some information needs a summary line followed by a blank line and a fuller explanation. Some details belong as attribute docstrings or additional docstrings, because they support the main story without interrupting it.
That structure is not cosmetic. It is a topology of attention.
A one-line docstring is the equivalent of a source node. It is the smallest possible statement that lets the reader start moving. It fits in one line because it is meant for really obvious cases, where the main job is orientation, not persuasion. A longer docstring, by contrast, acknowledges that some ideas need a summary first and elaboration second. The summary line gives the reader a foothold; the blank line creates a pause; the expansion fills in the dependencies.
This matters because readers do not read like compilers. They read in stages. They need a quick answer to “What is this?”, then a deeper answer to “How does it work?”, then a contextual answer to “When should I trust it?” A well structured docstring respects that order.
Consider a function called parse_date. A weak docstring might say only “Parse date.” Technically true, practically useless. A stronger one might begin: “Parse a date string into a timezone aware datetime.” That line gives the reader the essential shape. Then, after a blank line, a fuller description can explain accepted formats, error conditions, and edge cases. The reader is not forced to infer the missing dependencies. They are given them in sequence.
This is why the conventions around triple double quotes matter less as style trivia than as a signal of discipline. They create a visible boundary for explanation. They tell the reader: this is not just a comment, it is a structured aid to understanding. When done well, the docstring behaves like a topological order for meaning.
The deeper unity: both systems fight against hidden cycles
The most dangerous problem in both graphs and prose is not missing information. It is circularity.
In a graph, a cycle means no valid ordering exists. If task A depends on task B, and task B depends on task A, the system is stuck. Someone must break the loop by deciding what is truly prerequisite and what is merely assumed.
In documentation, cycles appear when an explanation assumes the very understanding it is supposed to create. For example, a comment might say, “This uses the standard approach,” while “the standard approach” is exactly what the reader needs explained. Or a docstring might define a term using another term that has not yet been defined. The prose loops back on itself, and comprehension stalls.
This is why the best documentation often feels modest. It does not try to say everything at once. It identifies sources, sinks, and the path between them. It begins with what can be understood immediately, then adds enough context to make the next step possible. In other words, it avoids cycles in meaning the same way topological sort avoids cycles in dependency.
A system becomes clear when it stops pretending every explanation can be self contained.
There is a more subtle lesson here too. Not every node needs the same amount of attention. In a dependency graph, sources are often simple, because they have no prerequisites. Sinks may be complex, because many paths lead into them. In documentation, the opening sentence should do one job, while later paragraphs can handle nuance. Clarity is not maximal detail. Clarity is correct placement of detail.
That is why the “summary line plus blank line plus elaboration” pattern is so powerful. It mirrors the actual shape of understanding. First you orient. Then you expand. Then, if needed, you drill down. This is not verbosity. It is sequencing.
A practical mental model: write and build in layers of dependency
If these ideas are truly connected, they should change how we work. They do not merely suggest “better docs” or “cleaner algorithms.” They suggest a general design principle: separate orientation from elaboration, and make dependency explicit before adding detail.
Here is a simple framework you can use in code, docs, planning, and teaching.
1. Identify the source nodes
Ask: what are the smallest pieces a newcomer can understand without prior context?
In code, this may be a function signature or a simple example. In documentation, it may be a one-line summary. In project planning, it may be the first prerequisite task. These are your sources, the places where movement can begin.
2. Find the sinks
Ask: what are the outcomes that depend on everything else?
In code, this may be a high-level workflow. In docs, it may be the full explanation, caveats, and edge cases. In a project, it may be the final integration or release. These are your sinks, the points where the system converges.
3. Make the path visible
Between sources and sinks, add the fewest steps necessary. Do not bury prerequisites inside the middle of the explanation. Do not describe a complex mechanism before the reader knows why it exists. A blank line, a short summary, a numbered sequence, or a bullet list can all serve as dependency markers.
4. Remove accidental cycles
Look for explanations that refer to terms not yet defined. Look for tasks that depend on deliverables not yet created. Look for comments that explain themselves by using the thing they are supposed to explain. Every cycle is an invitation to confusion.
5. Compress what is obvious, expand what is fragile
If something is genuinely obvious, one line may be enough. If something is ambiguous, consequential, or easy to misuse, it deserves elaboration. Good structure is not uniform. It is proportional to dependence.
This framework is useful because it scales. It works when you are writing a helper function, reviewing a design doc, onboarding a teammate, or explaining a complicated policy. The domain changes, but the topology of understanding stays the same.
What this means for better engineering and better thinking
The temptation in both software and communication is to believe that more detail automatically creates more clarity. It does not. More detail without order creates noise. More order without enough detail creates emptiness. The trick is to match the shape of the explanation to the shape of the dependencies.
That is why topological sort is such a beautiful metaphor for documentation. It reminds us that clarity is not a pile of facts. It is a sequence of access. The reader should not have to leap over missing prerequisites. The machine should not have to guess execution order. In both cases, the goal is the same: reduce friction between structure and comprehension.
Think about the best docs you have ever read. They probably did not feel impressive because they were exhaustive. They felt impressive because they were easy to enter. The first sentence opened a door. The second paragraph made the room intelligible. The later sections answered the questions that emerged only after the first ones were settled. That is topological thinking in prose.
Likewise, the best systems are not those with the fewest dependencies. They are those whose dependencies are honest. They admit what comes first, what comes later, and what cannot be done until something else is in place. That honesty is what makes them robust.
The mark of maturity is not eliminating dependency. It is arranging dependency so that others can move through it without confusion.
Key Takeaways
- Start with the source node: give readers or teammates the smallest possible entry point before adding complexity.
- Use structure to reveal dependency: summary first, elaboration second, details only after orientation is established.
- Watch for cycles in meaning: if an explanation depends on the thing it is supposed to explain, clarity will collapse.
- Compress the obvious, expand the fragile: one line is enough for the obvious; nuanced, risky, or ambiguous ideas deserve more space.
- Think in layers, not lumps: a good system, like a good docstring, lets understanding unfold in a valid order.
The real lesson: order is a form of respect
We often talk about order as though it were primarily about efficiency. But in the deepest sense, order is about respect. Respect for what depends on what. Respect for the limits of attention. Respect for the fact that understanding is sequential, even when reality is not.
That is the hidden kinship between topological sorting and good docstrings. One helps a machine do the right thing in the right sequence. The other helps a human do the same. Both recognize that clarity is not just about content, but about placement.
Once you see this, you start noticing it everywhere. In architecture, in teaching, in product design, in legal writing, in onboarding, in code review. The best systems do not merely contain information. They arrange it so that the next step becomes possible.
And that may be the most useful definition of good design of all: making the invisible order of dependencies visible enough that progress can begin.
Sources
Hatch New Ideas with Glasp AI 🐣
Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)
Start Hatching 🐣