These are chat archives for jdubray/sam

21st
Jul 2017
Victor Noël
@victornoel
Jul 21 2017 08:20
@jdubray the article is really good! things are clearer and clearer I think with it :)
Some comments though (because perfection):
  • I think the part explaining the assertion we must come to the realization that in an action-based programming model the concept of “control state” will have to be emulated in some ways, or the system will not be able to respond to actions correctly should be illustrated with pseudocode examples showing the problems explained in the text, it is exactly because it is a very simple example that it is the best place to illustrate what is the problem with purely actions-based approaches.
  • I wonder if there is not something wrong with the text just under fig 6 (there are words stuck together)
  • You should really reformat the fig 7, indentation and spacing is ugly :)
    Again, great work, the article made way much clearer many things for me :)
ah and one more comment: In the end, you say you should put code in one of the 3 buckets. I think the naming is confusing when you say State or Model, because when someone think "State" or "Model", he thinks of the result of the code that you put in that bucket, while what you call "State" or "Model" is the bucket itself. Maybe something like Model Mutator and State Computor (or whatever else) could make things clearer. I struggled a bit at the beginning with that, I didn't understand that State or Model are buckets to put code and not some data manipulated or created by those buckets.
Jean-Jacques Dubray
@jdubray
Jul 21 2017 13:43
@victornoel sorry for the indentations/table. I tried, but it looks like I should convert tables to jpeg and use blank spaces instead of tabs.
Happy you like it. SAM is a true software engineering pattern. Each time I took a corner on SAM semantics I regreated it. Right now I am working on a dashboard project and the requirements were very simple at first, just a few graphs, so I took the liberty to stash some calculations in the view components (these requirements were not very detailed either) then as I was able to deliver quickly these first few charts (that's was as far the project had gone before with months of work using R and a graphics package), then my client gave me N more charts to build (with corresponding APIs), plus some subtle requirements around the data structure,...
My initial decision to not use the State function to cleaningly compute the properties of the charts from the (data) Model was a deadly trap. I had to call it stop this week and ask for two weeks to refactor.
I will also refactor my initial decision to try to orchestrate complex queries with NAP which was also a very stupid decision. I just wanted to do like the Redux/Elm guys, which I believe people start seeing how broken that is.
I'll try to see if they let me edit the article afterwards, not sure.
@sladiri yes, this is a very important point, we want/need to program with the structure of a state machine but the State-Action behavior of state machines will make the code impossible to write. SAM suggests a new (heretic) behavior, the State-Action-Model behavior... Then each part of your code can reason cleanly about their own role.
When you are in the State function you only think about the State (machine) part of your code. You can rely on a stable snapshot of your Model (since we are passed the mutation phase f' -> f). How could you reason cleanly about state inside the mutation phase? unfortunately when you use Redux/Elm, MVC, ... that's what you do, because these phases are not cleanly delineated. It's the same for Action/Model, you could imagine that people may have a complex proposal to evaluate (including with API calls), it's just as ludicrous to start mutating before you know the whole proposal.
Jean-Jacques Dubray
@jdubray
Jul 21 2017 13:48
We have been writing billions of lines of codes for more than six decades under these three approximations (i.e. without that delineation) and that needs to stop.
I want to thank everything one on this forum for all the stimulating discussions, I don't think I could have come up with this (at least for me) clear view of what the pattern changes, without all the stimulating questions that were asked.
But at this point, I truly believe SAM is new and I hope significant.
Jean-Jacques Dubray
@jdubray
Jul 21 2017 13:56
The article is in DZone's spotlight today!
image.png
Jean-Jacques Dubray
@jdubray
Jul 21 2017 14:36
Jean-Jacques Dubray
@jdubray
Jul 21 2017 16:36

@victornoel The paradigm shift can be summarized in this paragraph:

In structured programming, correctness is achieved with the use of conditional expressions: “if-then-else” or “switch-case”, which tend to focus the attention of the developer on the what needs to happen, i.e. mutation, actions, without requiring the precise identification of (control) states nor if the mutation is complete, i.e. where the system/code is currently at