grokking_simplicity/ch06

ch06

dz / grokking_simplicity / ch06

Summary

Grokking Simplicty Chapter 6: Staying immutable in a mutable language

Node Tree

Nodes

operation
content Operation can be categorized as a read or write

COW_discipline
content Copy-on-write discipline: make copy, modify copy, return copy

read_and_write
content What about a function that does both a read and write?
children shift (example of function that does both read/write)

shift
content Example: shift function. Returns first value, shifts array function
children either_shift_refactor
parents read_and_write

either_shift_refactor
content Either
children split_up_into_2, return_2_values
parents shift

split_up_into_2
content Split up into 2 functions
parents either_shift_refactor

return_2_values
content Return 2 values from function
parents either_shift_refactor

immutable_reads_calculations
content Reads to immutable data structures are calculations
children mutable_reads_actions (Corollary), convert_writes_reads

mutable_reads_actions
content Mutable reads are actions
parents immutable_reads_calculations

writes_data_mutable
content Writes make data mutable

convert_writes_reads
content converting writes to reads makes more calculations
parents immutable_reads_calculations
remarks I'd like to understand this better. examples are in the book fortunately.

shallow_copy
content Shallow Copy: only duplicate top-level structure of nested data

structural_sharing
content Structural Sharing: two pieces of data shrae some of their references

nested_data_cow
content Nested data and copy-on-write make efficient use of references
children only_parts

only_parts
content only parts of structure need to be replaced
parents nested_data_cow