Skip to content

Commit 858b101

Browse files
Liampronansarahhaggarty
authored andcommitted
update: minor changes async-programming.md
- "titled (sp) christmas tree" -> pyramid of doom - clarify promise description
1 parent f1e3756 commit 858b101

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/topics/async-programming.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ fun preparePostAsync(callback: (Token) -> Unit) {
6161
This in principle feels like a much more elegant solution, but once again has several issues:
6262

6363
* Difficulty of nested callbacks. Usually a function that is used as a callback, often ends up needing its own callback. This leads to a series of nested callbacks which
64-
lead to incomprehensible code. The pattern is often referred to as the titled christmas tree (braces represent branches of the tree).
64+
lead to incomprehensible code. The pattern is often referred to as callback hell, or the [pyramid of doom](https://en.wikipedia.org/wiki/Pyramid_of_doom_(programming)) due to the triangular shape that indentations from these deeply nested callbacks create.
6565
* Error handling is complicated. The nesting model makes error handling and propagation of these somewhat more complicated.
6666

6767
Callbacks are quite common in event-loop architectures such as JavaScript, but even there, generally people have moved away to using other approaches such as promises or reactive extensions.
6868

6969
## Futures, promises, and others
7070

71-
The idea behind futures or promises (there are also other terms these can be referred to depending on language/platform), is that when we make a call, we're promised
72-
that at some point it will return with an object called a Promise, which can then be operated on.
71+
The idea behind futures or promises (other terms may be used depending on the language or platform), is that when we
72+
make a call, we're _promised_ that at some point the call will return a `Promise` object, which we can then operate on.
7373

7474
```kotlin
7575
fun postItem(item: Item) {

0 commit comments

Comments
 (0)