Separate distinct responsibilities into independent abstractions, then compose them. A MultiDict owns multiple values per key, while TodoList adds behavior specific to to-do lists. section 4.1.2
Keep HTTP at the boundary
Parse request parameters and format responses in the web layer, but delegate operations to HTTP-agnostic domain code such as Todo.Server. This keeps the core easier to work with, test, and expand. section 11.3.3
Listing 4.4 Implementing the MultiDict abstraction (todo_multi_dict.ex)
defmodule MultiDict do
def new(), do: %{}
def add(dict, key, value) do
Map.update(dict, key, [value], &[value | &1])
end
def get(dict, key) do
Map.get(dict, key, [])
end
end
Inspect the MultiDict implementation that isolates keyed collection behavior from TodoList responsibilities. section 4.1.2





















