I think it's a bit bad practice to mix your model data with the model functions/state
this is wiring, you can wire the pattern in any way you'd like
The constraints of the pattern are only:
This factoring is "unique", you just can't make it up (IMHO)
You can define formalisms on top of it, but you cannot decide arbitrarily what the foundation is, it is foundational.
you can't throw up any formalism in the air and say that one works too,
My point is that TLA+ is a formalism which can be used to describe any state machine as we know it, therefore I claim it is foundational.
Except that there is a very, very fundamental difference here
SAM state machines are not of the kind (S1,A,S2)
If that was the case, you would be correct
As I mentioned the structure of (S1,A,S2) is an approximation
The SAM pattern can be described as a Mathematical expression (formula):
V = S( vm(M.present(A(data))), nap(Model) )
However, that expression is only a logical expression that describes the sequence in which the elements of the pattern are invoked.
Where S(), vm(), A() and nap() are pure functions with respect to the model.
Thank you for your insights. This has been the starting point of SAM
Much of computer science is about state machines. This is as obvious a
remark as saying that much of physics is about equations.
State machines provide a framework for much of computer science. They
can be described and manipulated with ordinary, everyday mathematics—
that is, with sets, functions, and simple logic. State machines therefore
provide a uniform way to describe computation with simple mathematics.To describe a program as a state machine, we must decide what constitutes
a step. How many steps are performed in executing the statement
f = i ∗ f of the programs in Figure 1? Does a single step change the value
of f to the product of the current values of i and f ? Are the evaluation of
i ∗ f and the assignment to f two steps? Are there three steps—the reading
of i, the reading of f , and the assignment to f ?
That has been exactly the path I took when designing SAM, what are "steps" involved in processing an event and rendering the effects, with the understanding that you cannot ignore the semantics of the State Machine behind, actually, I would argue that any formalism that is derived without consideration of the underlying state machine is most likely flawed.
As Dr. Lamport states (pun intended):
The obsession with language is a strong obstacle to any attempt at unifying
different parts of computer science. When one thinks only in terms
of language, linguistic differences obscure fundamental similarities. Simple
ideas can become complicated when they must be expressed in a particular
language. A recurring theme is the difficulty that arises when necessary
concepts cannot be introduced either because the language has no way of
expressing them or because they are considered to be politically incorrect.
CQRS sense
but a mapping of user input?const model = {}
// cat name space
model.Cat = {}
model.Cat.list = []
// dog
model.Dog = {}
model.Dog.list = []
model.present = (data) => {
// only one present for both Cat and Dog
}
///
// OR I can have present for Cat and Dog?
///
model.Cat.present = (data) => {
}
model.Dog.present = (data) => {
}
Modularizing the model is not clear for me, when you say
There is no problem modularizing the model as needed as long as Actions "present" proposals to the model and these proposals are serialized
because in SAM site says:
The model contains all the application state and (logically) exposes a single method: present(data)
I could do this?
const model = {}
model.present = (data) => {}
// I could do, instead of having if's in present?
model.presentNewtItem = (data) => {}
model.presentEditItem = (data) => {}
action.addNewItem = (data, present) => {
present = present || model.presentNewItem;
// all actions need
present(data)
}