Skip to content

Commit 4d693ef

Browse files
committed
Add Desirable Properties article
1 parent 0182509 commit 4d693ef

File tree

4 files changed

+99
-1
lines changed

4 files changed

+99
-1
lines changed

apps/components_guide_web/assets/css/app.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ a:hover {
6666
h1,
6767
h2,
6868
h3,
69+
h4,
6970
p,
7071
li,
7172
table,
@@ -89,6 +90,10 @@ h3 {
8990
font-size: var(--heading-3-size);
9091
padding: var(--heading-3-spacing);
9192
}
93+
h4 {
94+
font-size: var(--heading-4-size);
95+
padding: var(--heading-4-spacing);
96+
}
9297
p {
9398
padding: var(--paragraph-spacing);
9499
}
@@ -140,6 +145,8 @@ pre {
140145
--heading-2-spacing: var(--size-base) 0;
141146
--heading-3-size: var(--size-2xl);
142147
--heading-3-spacing: var(--size-base) 0;
148+
--heading-4-size: var(--size-xl);
149+
--heading-4-spacing: var(--size-base) 0;
143150
--paragraph-spacing: 0.5rem 0;
144151
--listitem-spacing: 0.5rem 0;
145152
--table-spacing: var(--size-xl) 0;

apps/components_guide_web/lib/components_guide_web/controllers/composable_systems_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule ComponentsGuideWeb.ComposableSystemsController do
66
render(conn, "index.html", article: "intro")
77
end
88

9-
@articles ["opinionated-vs-flexible"]
9+
@articles ["opinionated-vs-flexible", "desirable-properties"]
1010

1111
def show(conn, %{"id" => article}) when article in @articles do
1212
render(conn, "index.html", article: article)

apps/components_guide_web/lib/components_guide_web/templates/composable_systems/_nav.html.eex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<ul y-y x-x=md class="text-lg font-bold" style="--link-padding: 0.75em">
33
<li><%= link("Why?", to: '/composable-systems') %>
44
<li><%= link("Opinionated vs Flexible", to: '/composable-systems/opinionated-vs-flexible') %>
5+
<li><%= link("Desirable Properties", to: '/composable-systems/desirable-properties') %>
56
<li hidden><%= link("Single Responsibility", to: '/composable-systems/roles') %>
67
<li hidden><%= link("Deterministic", to: '/composable-systems/roles') %>
78
</ul>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Desirable Properties
2+
3+
<h2>Values</h2>
4+
5+
<h3 id=deterministic>Deterministic</h3>
6+
7+
- A given input always produces the same output
8+
- Easily Cacheable
9+
- Verifiable by multiple actors
10+
- *e.g. Converting to lowercase or uppercase*
11+
- *e.g. Concatenating strings*
12+
- *e.g. SHA256 hash digest (RFC 6234)*
13+
- *e.g. Base64 encoding/decoding (RFC 4648)*
14+
- *e.g. Gzip decoding (RFC 1952)*
15+
16+
```console
17+
# Converting to lowercase
18+
> echo "AbC" | tr "[:upper:]" "[:lower:]"
19+
abc
20+
21+
# SHA256 hash digest
22+
> echo "abc" | shasum -a 256
23+
edeaaff3f1774ad2888673770c6d64097e391bc362d7d6fb34982ddf0efd18cb -
24+
25+
# Base64 encoding
26+
> echo "abc" | base64
27+
YWJjCg==
28+
29+
# Base64 decoding
30+
> echo "YWJjCg==" | base64 -d
31+
abc
32+
33+
# Gzip decompressing
34+
> echo "H4sIADFoHGAAA0tMSuYCAE6BiEcEAAAA" | base64 --decode | gzip --decompress
35+
abc
36+
```
37+
38+
<h3 id=unique>Unique</h3>
39+
40+
- Unique within a context or globally unique?
41+
- Won’t clash with existing values
42+
- *e.g. UUID (RFC 4122)*
43+
- *e.g. SHA256 hash digest (RFC 6234)*
44+
- Could still be guessable: *e.g. Auto increment SQL primary key*
45+
46+
```console
47+
# UUID
48+
> uuidgen
49+
5F36D0E2-F524-46B8-870B-9AA70128F8AF
50+
```
51+
52+
<h3 id=random>Random</h3>
53+
54+
- Not [Guessable](#guessable)
55+
- Should never clash with existing values
56+
- *e.g. UUID v4*
57+
- *e.g. Cryptographically Random source*
58+
59+
<h3 id=guessable>Guessable</h3>
60+
61+
- Not Secure
62+
- Not [Random](#random)
63+
- *e.g. Auto increment SQL primary key*
64+
65+
----
66+
67+
<h2>Acts</h2>
68+
69+
<h3 id=immutable>Immutable</h3>
70+
71+
- Benefits caching
72+
- Benefits syncing
73+
- *e.g. Twitter tweets are not editable*
74+
- *e.g. a Git commit*
75+
- *e.g. a YouTube video cannot be edited*
76+
77+
<h2 id=stateless>Stateless</h2>
78+
79+
- Is [Deterministic](#deterministic)
80+
- *e.g. A Restful
81+
82+
<h2 id=idempotent>Idempotent</h2>
83+
84+
- e.g. receiving at least once events
85+
- Could use Random identifier in request to record which commands have already been completed
86+
87+
<h2 id=versioned>Versioned</h2>
88+
89+
- Won't break previous usages
90+
- *e.g. [Stripe’s API Versioning](https://stripe.com/blog/api-versioning)*

0 commit comments

Comments
 (0)