'State' instead of 'Model'?


#22

A rose by any other name would smell as sweet. But naming conventions are important. They reduce mental overhead when understanding source code. They reduce pointless debates when reviewing code.

This discussion has more to do with shared language and definitions of words than it does with programming. The fact that the guide calls it a Model, the inventor calls it a Model all the tutorials on the internet call it a Model and folks in the #beginners channel on slack refer to it as the Model is a strong indicator to use the term. It’s shared language — which is what communication is all about.

But what about sharing language with newcomers? This is important too — many have commented that they immediately refer to the Model as the application state. I do not. In the Angular world state can be local to components. So I stay away from the term state. Instead I explain the Model is the central data structure for your application, is represented to the user in the view function and is moved forward in the update function. It’s important to model it correctly. Modeling is what the Model is all about! State is a major part of it — but again, I don’t think it’s helpful to focus on it because in the javascript world many times state is not central, updating state is not pure, mutable state is allowed etc.

Many fun words got defined before Elm hit the scene in 2012:













#23

That’s actually an unhelpful analogy since the model in MVC does not capture all application state (only “data”), while Elm’s model does.

“State” is also taught in schools, usually along the lines of “program counter, register content, memory content” (ignoring other I/O). That’s much closer to what Model is in Elm.


#24

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.