Actions:
Anything that depends on when it is run, or how many times it is
run, or both, is an action.
Calculations
Calculations are computations from input to output. They always
give the same output when you give them the same input.
Data
Data is recorded facts about events.
* Serializable, Compare for equality, Open for interpretation
Notes:
pp.11 Once computers talk over networks, things get chaotic. Messages
arrive out of order, are duplicated, or never arrive at all. Making
sense of what happened when, basically modeling change over time, is
very important, but also difficult. The more we can do to eliminate
a dependency on when or how many times, the easier it will be to
avoid serious bugs.
Data and calculations do not depend on how many times they are
run or accessed. By moving more of our code into data and calculations, we sweep that code clean of the problems inherent in distributed systems.
pp.13 three important ideas are
1) distinguishing actions, calculations, and data, 2) using first-class
abstractions, and 3) building
composable models.
pp.62 Ch.4 Extracting calculations from actions
Q: Are reusability and testability the only concerns that functional programming helps with?
A: Absolutely not! FP does help with those, but there’s a lot more out
there. We’ll get to concurrency, architecture, and data modeling by the
end of the book. Also, FP is a big field and this book cannot cover all of
it.
Copy-on-Write
Make a copy, Modify the copy, Return the copy
Making copies allows us to keep the original and the copy without
worry that it will change. This is great for implementing undo/
redo.
JavaScript Object Copy
var item_copy = Object.assign({}, item);