These are chat archives for jdubray/sam-examples

26th
Feb 2016
bgusach
@bgusach
Feb 26 2016 08:08
@HighOnDrive programming rock band? :D you take this business seriously!!
bgusach
@bgusach
Feb 26 2016 15:39
Got a question, how can actions be pure functions if they can call third party APIs which may not be pure? That is not quite the definition of pure functions...
bgusach
@bgusach
Feb 26 2016 15:57
And, moreover... they just produce side effects... that is the opposite of function purity
Jean-Jacques Dubray
@jdubray
Feb 26 2016 15:59
they are pure fonctions with respect to the model
It is only with respect to the model
bgusach
@bgusach
Feb 26 2016 19:10

Uhm... I don't find it very intuitive to be honest.

Your idea might be brilliant, but I really can't understand it properly. You talk about pure functions (that return nothing and can perform almost any action), then the equations that describe your model have this term M.present( A(data) ), which I can't understand since the action functions return nothing. I also find kind of confusing that the SAM acronym stands for State-Action-Model, but when I take a look at your examples, I can see there is a fourth element called view (and so far I cant get my head around about the idea that state and model are different things, but maybe because something has not clicked yet in my brain)

I don't know, I am no specialist in this domain and maybe I'm trying to bite more than I can chew, but I think you have to make your material more didactic. Just my respectful opinion.

Jean-Jacques Dubray
@jdubray
Feb 26 2016 20:08
Yes, your point is valid, the difficulty comes from expressing a reactive loop from an expression. Logically the view is computed from that expression. However, the pattern is reactive so it is the action which calls the present function, which can be viewed (and probably should be) a closure on the model.
All actions as structured as:
function action(data,present) {
      var data_ = purefunctionAction(data) ;
      present(data_) ;
}
And for the model:
function present(initialState) {
      var model =initialState  ;

      return ( function (data) {

              ... implementation of the present method ...
      } ) ;

}
Jean-Jacques Dubray
@jdubray
Feb 26 2016 20:13
Again, there is only so much you can express in a single expression, hopefully it still helps to understand the pattern.

I think you have to make your material more didactic.

yes, but that only happens over time, as people ask question and I understand where the disconnects happen

The View is the "State" representation. It is totally subject to the "State", it cannot stand on its own. I believe that has been one of the root cause of all MVX patterns, it is best to think in terms of business logic only because the view has none, that's why the pattern is not called VSAM (disclosure doesn't sound as good). That being said, V, the state representation, can actually be anything, SAM is really the pattern.