These are chat archives for jdubray/sam

17th
Feb 2018
Daniel Neveux
@dagatsoin
Feb 17 2018 11:30

In my new job, I will use redux a lot. I haven't touch it for years, but as I think I have a good understanding now of the SAM pattern, I wonder where the points of friction are. During the last exchange I saw:
1- many to many relation between action and mutations
2- model mutation only knows the few fields it cares about in the proposal (so it does know the whole proposal structure)

So for point 1 by using action creators, you can compose a proposal from multiple actions (as an action creator could call other action creators).

For point 2, as the proposal contains a ( loosely coupled as it could be a string ) name of the mutation, the model can pick just what it needs in the proposal. So the decoupling seems to be respected.

For the next steps of the loop, we can use a listener to trigger the State function and generate a new View/ViewModel, ControlState, etc.

Also I don't see action mutating the state. The action, as in SAM, doesn't mutate the state but proposes a value. The reducer (the acceptor) can check the value and reject as well.

The only difference I see is the immutability that redux relies on.

Fred Daoud
@foxdonut
Feb 17 2018 13:06
@dagatsoin That is a great explanation! I think you are correct, that's the way I see it as well. Although, I would add one more important point: the way to handle asynchronous actions in Redux. I haven't looked at Redux in a while either, something may have changed, but that was a pain point.
Daniel Neveux
@dagatsoin
Feb 17 2018 13:09
yes asynchronous seems to be a specific case involving plugins. But I wonder if the action creator can't just act as a normal asynchronous action, aka return "loading: true" first and then dispatch another action when the data is received.
need to try.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:24
@dagatsoin I would say 2/ is not a problem in Redux, you get that capability from dynamic typing. As @foxdonut mentioned async actions, especially API calls are more problematic. Lots of options with no clear winner/guidance.
I would throw immutability somewhere in there because it will most certainly get in the way.
Redux does not encourage (but does not prevent) the delineation action/mutation/state representation. This means that if you are not careful you will end up implementing reducers with all three concerns in one big blob of code.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:29
Redux 101 is like Elm: event -> update -> render. It does not help that Redux calls event "actions".
Daniel Neveux
@dagatsoin
Feb 17 2018 13:31
For immutability, I would argue that is isolated into the model. Imagine the model is hosted on a server, I won't really care if it acts with immutability or not. I just need to be sure that the State function will handle the last updated version of the model.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:31
In particular, that leaves no room for API calls, they are treated outside the core programming model, as an after thought.
yes, that works. Immutability introduces only a performance concern, there are no logical implications to using immutable data structures.
Daniel Neveux
@dagatsoin
Feb 17 2018 13:33
Yes, API call is the last point. I need to write some examples because I regressed to the noob zone with Redux.
boris sabadach
@bsabadach
Feb 17 2018 13:37
Hello everyone: @jdubray ‘no romm for API calls’, you already mentioned that CRUD operations should be done inside the model, didn’t you?
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:37
I don't think it's hard to solve, it's just that the prevalent guidance feels like too much boilerplate, and appears to be due to some FP cargo cult.
@bsabadach actually, Create/Update/Delete API calls. Queries should be called from actions.
That's only a UX-based recommendation, in general CUD calls are "synchronous" from a UX perspective, the user wants to know the result before doing anything else.
Theoretically they should all be made from an action, not from the model.
Daniel Neveux
@dagatsoin
Feb 17 2018 13:39
I think that CRUD in model is intended just for persistance. (won't influence on the model)
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:39
This is really the Command/Query dichotomy. Commands in model, Queries in action.
Daniel Neveux
@dagatsoin
Feb 17 2018 13:40
yep
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:40
Queries can be cancelled, but Commands cannot, they need to be compensated.
boris sabadach
@bsabadach
Feb 17 2018 13:41
@jdubray how do you cancel an API call?
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:44
I implemented a generic mechanism in SAM-SAFE using a temporal relationship (fancy term for counter). You can associate an action instance (calling the query) to the current model step. If another proposal is received before the action's proposal, then the model can safely ignore the stale proposal because it came "out-of-step". Each time the model receives a proposal it will increment its counter.
Sorry I marvel at simple things, that's the power of temporal logic.
boris sabadach
@bsabadach
Feb 17 2018 13:45
well so you don(t cancel when api is invoked because i think it’s not feasible in ES6
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:46
That is the kinds of construct that I feel are missing in modern programming languages. FP kinds of try to get you there with pure functions, but that is so rudimentary.
Exactly, it's not possible to "undo" the call
Your best bet is to ignore the response
But even that is quite difficult without proper temporal logic constructs.
Netflix seemed to have struggled building it.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:52
In general, people using dedicated ancillary state machines to cancel API calls, for instance:
const fetchUserEpic = action$ =>
  action$.ofType(FETCH_USER)
    .mergeMap(action =>
      ajax.getJSON(`/api/users/${action.payload}`)
        .map(fetchUserFulfilled)
        .takeUntil(action$.ofType(FETCH_USER_CANCELLED))
    );
boris sabadach
@bsabadach
Feb 17 2018 13:53
is it RXJS code?
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:54
IMHO, it's better to let the model decide.
Yes this looks like it.
boris sabadach
@bsabadach
Feb 17 2018 13:55
btw I have struggled to do forms validations: where do u put it?
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:55
Actions should be "pure" from an application state perspective. I know that people disagree with my definition of "pure", but actions must be entirely disconnected from application state.
We spoke about it recently.
boris sabadach
@bsabadach
Feb 17 2018 13:56
you validate fields with actions?
Jean-Jacques Dubray
@jdubray
Feb 17 2018 13:57

If you search for "validation" this thread comes up on top:

@srconklin there are two types of validation:

  • activity level validation
  • domain validation
IMHO, actions are responsible for event (and event payload) validation, focused on the "activity". Any domain validation should happen in the model.
The rendering is standard functional HTML5/CSS3 stuff, using V = f(M).
Daniel Neveux
@dagatsoin
Feb 17 2018 13:59
If you validate the data on the server, the API call can be done in the action. And the potential error returning by the server can be store in the model.
(For example in a map of field/error)
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:00
absolutely, that's kind of the beauty of programming model, you now have full flexibility on the architecture. Actions, Model and State Representation can run anywhere in the stack.
boris sabadach
@bsabadach
Feb 17 2018 14:01
usually I create a formModel that is difrent form the model
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:06
Yes, as I mentioned in the discussion, SAM's composition model parent/child works well. That being said, the component model I use hardly makes it necessary to use it.
Fred Daoud
@foxdonut
Feb 17 2018 14:08
@jdubray as a "peace offering" to you :) I have tried to write a Meiosis example that more closely follows the SAM pattern. If you still don't approve of it, I won't mention SAM in the context of Meiosis in the future. I respect your view and I don't want to do any "false representation".
I tried to structure a Meiosis example to be more SAM-like. You can see the example running here and the source code.
  • acceptor.js is the equivalent of model.present. Instead of having one big function that accepts all proposals, with a series of if/else statements, I have named functions, but the idea is the same. The acceptor updates the model by calling update, and this triggers the reactive loop.
  • actions.js contains the actions called by the view. These handle DOM events and send proposals by calling functions on the acceptor.
  • state.js is a function that can "shape" the model for the view to consume. Here it's just a simple example, adding a HOT or COLD comment according to the temperature.
  • view.js is the view, it simply displays the view and calls actions from DOM events.
  • index.js is the Meiosis pattern which sets up the reactive loop.
    I have a view as a function of the model/state; actions send proposals to the acceptor; the acceptor updates the model; an (optional) state function can produce a state representation from the model. The only thing I don't have is nap().
    What do you think?
boris sabadach
@bsabadach
Feb 17 2018 14:09
The problem for me is that you mix domain model and presentation model. Especially in the wizard example. The step of a wizard should be dependent on domain model: the wizard would not be a reusable component. Some components need to have their own local "state"
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:09
I am not at war :-) I am trying to be objective.
boris sabadach
@bsabadach
Feb 17 2018 14:09
"should not be dependent" sorry
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:11
yes, agreed but logically there is no difference between local and global. I mentioned a few days ago that I am working on a generic way to fold local state in the application state.
Fred Daoud
@foxdonut
Feb 17 2018 14:12
Note that if you don't like the named functions in acceptor, it would be trivial to have just one present function that accepts proposals.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:12
appState.components['my-stateful-component-1'].state
@foxdonut I don't get caught up in naming or syntax, I am only uptight about semantics.
I just prefer "present" because it's more neutral than accept, but it really doesn't matter. I also call the mutation blocks "acceptors".
Janne Siera
@jannesiera
Feb 17 2018 14:14

I implemented a generic mechanism in SAM-SAFE using a temporal relationship (fancy term for counter). You can associate an action instance (calling the query) to the current model step. If another proposal is received before the action's proposal, then the model can safely ignore the stale proposal because it came "out-of-step". Each time the model receives a proposal it will increment its counter.

How do you determine if a proposal is "stale"? Would only the last action called be able to propose? E.g. action A starts a query and proposes the result to the model. While the action is waiting for the result, the user triggers action B which immediately proposes a mutation of some unrelated state. Would the result of A always be rejected?

Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:16
@jannesiera yes, correct, this is achieved by "counting" the number of proposal received and associating an action instance to that number. When the action sends it's proposal the model can compare its "current" step with action instance step. This is temporal logic at its best.
Fred Daoud
@foxdonut
Feb 17 2018 14:16
@jdubray I understand. I would appreciate your comments on the example so that I know whether you consider it valid SAM or not.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:16
That's why counters are found throughout the work of Dr. Lamport. They are the essence of Temporal Logic.
@foxdonut I am looking one second.
Janne Siera
@jannesiera
Feb 17 2018 14:18
@foxdonut that example is extremely similar to Vuex.
boris sabadach
@bsabadach
Feb 17 2018 14:19
I don’t understand the need to push local state to global state. what is the « appState »? a model or a "control state"
Janne Siera
@jannesiera
Feb 17 2018 14:19
@jannesiera yes, correct, this is achieved by "counting" the number of proposal received and associating an action instance to that number. When the action sends it's proposal the model can compare its "current" step with action instance step. This is temporal logic at its best.
But it only handles one case of temporal logic, where only the last actions is valid.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:20
@bsabadach appState is the application state.
Janne Siera
@jannesiera
Feb 17 2018 14:20
So if I have a screen with two lists, with their own "refresh" button and click both in succession, either one or two will refresh.
Depending on the order in which the queries return.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:21
@jannesiera this gives the foundation to implement any behavior you like. You now have the concept of "time" (granted not human time) and ordering in your programming model. That's not something that's easy to achieve in any other way.
@foxdonut so, I am concerned with this:
export const createActions = acceptor => ({
  togglePrecipitations: evt => acceptor.togglePrecipitations(evt.target.checked),

  changePrecipitation: evt => acceptor.changePrecipitation(evt.target.value),

  editDate: evt => acceptor.editDate(evt.target.value),

  increase: amount => () => acceptor.increase(amount),

  changeUnits: () => acceptor.changeUnits(),
});
Fred Daoud
@foxdonut
Feb 17 2018 14:22
@jannesiera if you say so... I don't know anything about Vuex. I know a bit about Vue.js, personally it is not what I would like to use to write web apps.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:22
this is the coupling that I feel is wrong. an action cannot be wired in any way to an acceptor.
boris sabadach
@bsabadach
Feb 17 2018 14:23
what is application state is for you: for me there is a UI state and a model state so application state is the UI application state and has to do with routing; the active view matching a route
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:23
The coupling is only at the proposal level, and not even the proposal structure (type), only the proposal's props.
Janne Siera
@jannesiera
Feb 17 2018 14:24
@foxdonut I'm using Vuex every day now. It's almost exactly the same. Just rename acceptors to mutations and state to getters and you're there.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:24
@bsabadach for me there is no UI state, the UI is computed functionally from the State Representation which itself is computed functionally from the application state (Model property values).
Fred Daoud
@foxdonut
Feb 17 2018 14:24
@jdubray can you give me an example of what that code should look like instead?
boris sabadach
@bsabadach
Feb 17 2018 14:25
@jannesiera I agree
Fred Daoud
@foxdonut
Feb 17 2018 14:25
perhaps something like
export const createActions = Model => ({
  togglePrecipitations: evt => Model.present({ togglePrecipitations: evt.target.checked }),
  ...
});
?
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:25
@foxdonut yes, exactly.
@jannesiera yes, I would agree, it looks very similar.
Fred Daoud
@foxdonut
Feb 17 2018 14:26
@jdubray thanks, I can do that... I will update the example. Anything else that would make the example SAM-compliant?
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:26
Still parsing the code.
boris sabadach
@bsabadach
Feb 17 2018 14:27
@jdubray for an accordion for example , its state (expanded / folded) is related to user interaction whatever the model is.
Janne Siera
@jannesiera
Feb 17 2018 14:28
@jdubray @foxdonut Sorry, but I see no difference between the named function and presenting to the model with an object field. That's just a different syntax for the same semantics and is coupled in the same way. (Although it does make it even closer to Vuex, as it works with "commit(payload)")
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:29
@bsabadach I do use JQuery components (e.g. Datatables) which have their own state outside of the SAM application state, that's not incompatible.
The problem is more around the intersection between model/application state and component state.
Janne Siera
@jannesiera
Feb 17 2018 14:30
@bsabadach Until you want to expand / fold the accordion according to whether a user is logged in or not on page load, save accurate UI state in localstorage, etc
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:30
If the intersection is empty then it's a non issue.
boris sabadach
@bsabadach
Feb 17 2018 14:30
ok that’s what I meant
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:31
@foxdonut everything looks great, I wish I could write pretty JS like that. That being said, I am curious to see how you will implement that acceptors now.
Janne Siera
@jannesiera
Feb 17 2018 14:32
Imho there is no difference UI State / Application State. State is state. If the application you are building is a User Interface, then your application state is the UI state.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:33
@bsabadach for me functional HTML is what changed everything, so I am a strong believer in V = f(M), even though HTML has a few corner cases that break that paradigm or would degrade the UX if you implemented in a functional way rather than with DOM manipulations
Fred Daoud
@foxdonut
Feb 17 2018 14:34
@jdubray thank you for having a look! I appreciate it. I will update the example and post here when it's done.
boris sabadach
@bsabadach
Feb 17 2018 14:34
@jannesiera yes it depends on the use case. But think of a reusable accordion, you need to have local state that is mutated relatively to application logic. Or how do you use third party widget libraries , or your own enterprise component catalog.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:34
@foxdonut always happy to take a look at your work!
boris sabadach
@bsabadach
Feb 17 2018 14:34
@foxdonut can I have a look?
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:35
@bsabadach This sample actually shows how you can still achieve a functional HTML paradigm using higher order functions: https://glitch.com/edit/#!/plain-frog?path=views/index.html:1:0
you can see the sample running here
Fred Daoud
@foxdonut
Feb 17 2018 14:36
@bsabadach of course, I appreciate everyone's feedback! See above for the links.
Janne Siera
@jannesiera
Feb 17 2018 14:37
@bsabadach its a tricky question. And often it makes sense to have local state, until it doesn't anymore. If you use 3rd party components it depends on their implementation. If they are completely controllable by 'overwriting' their state by setters (attributes and props) and expose their inner state by events, then it should technically enable you to to control of whatever state you want, whenever.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:38
@foxdonut please note that in general the actions will have a broader role than just translating an event into a present call.
Actions validate (from an activity perspecitive), transform and enrich events, and if this is a concern there should also be a container like SAM-SAFE to validate that the event it legit.
In general that is not a concern because the view holds the last state representation which from a REST's perspective holds all the allowed actions, but there are cases where concurrency requires a tighter implementation.
What you want to avoid in general is the action to have to "get" extra values from the model. The action should only work from the event payload data. If additional application state is necessary, it should be passed in the state representation, not accessed directly from the model.
Fred Daoud
@foxdonut
Feb 17 2018 14:46
@jdubray agreed. The actions are simple in this example, but they could do any and all the work that they need to do to formulate a proposal. Also, I agree with you, this is where async API calls would happen.
As well the state function constructs the state representation.
boris sabadach
@bsabadach
Feb 17 2018 14:48
@jannesiera agree, the problem is that third party libraries components are not always built like that. And thus IMHO application state is only the router state. I build applications with ‘vertical silos’ called modules and the application only make the glue with these independant modules; a module can be throwed away easily and replaced by another one. So these local component state are most the responsibility of the module state. I don’t have a global state like redux. For me it’s breaks the modularity for business applications
Jean-Jacques Dubray
@jdubray
Feb 17 2018 14:53
@bsabadach I disagree with that. that's only true in a statically typed world. Local state can be folded in global state.
The key is to drive application architecture towards functional HTML, for me that's a benefit that I cannot pass on.
The folded components can be made reusable.
If I get some time over the week-end I'll try to complete the example
boris sabadach
@bsabadach
Feb 17 2018 14:56
I don’t know why having modules without global state prevent you to make functionnal HTML
Jean-Jacques Dubray
@jdubray
Feb 17 2018 15:00
@bsabadach could show me how you achieve it? I can't.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 15:06
The component state would only be valid until it's rerendered from the state representation.
boris sabadach
@bsabadach
Feb 17 2018 15:12
Each module has it’s own SAM container
Jean-Jacques Dubray
@jdubray
Feb 17 2018 15:13
That's overly complicated, you can do better by simply folding the component state in the app state.
boris sabadach
@bsabadach
Feb 17 2018 15:16
With the size of the application I worked on last year, I can’t imagine the size of the global state : unless I don’t understand what is application state
Daniel Neveux
@dagatsoin
Feb 17 2018 15:20
Personnaly the engine I am writing do both. It is a tree where each node is a SAM container. From the above it acts exactly as one big model but with the perf of a subdivises model.
boris sabadach
@bsabadach
Feb 17 2018 15:22
@dagatsoin why do you need a single tree?
Daniel Neveux
@dagatsoin
Feb 17 2018 15:25
You can have as many tree as you want.
Maybe I missunderstood the conversation... my point is SAM does not force to have a single state.
Coorection: SAM does not force to have a single model in your whole app. But it forces, as a container, to have a single model for a single State function.
(sry I am on mobile...)
Daniel Neveux
@dagatsoin
Feb 17 2018 15:31
So that brings to composition or to parralism if you want a single state tree or both side by side.
So I think you are both right in a way :smile:
boris sabadach
@bsabadach
Feb 17 2018 15:31
@dagatsoin yes that’s what I meant to say.
Perhaps my English is not that good
Jean-Jacques Dubray
@jdubray
Feb 17 2018 15:39
You can have as many trees as you'd like, but they can only communicate via actions to align their state. Sometimes that's the right paradigm, however is you have a simple, yet stateful component, it's easier (IMHO) to fold the state into a single SAM instance. I don't see any downside.
VaseJS
@VaseJS
Feb 17 2018 15:41
i’m starting to see why Lamport use math to communicate. There is a lot of talking but its too abstract without code to make sure everyone is actually saying the same thing, which in most cases doesn’t seem to be the case.
talking without code == confusion
Jean-Jacques Dubray
@jdubray
Feb 17 2018 15:42
I agree, it's better to talk over a code sample.
VaseJS
@VaseJS
Feb 17 2018 15:43
i’ve been watching this conversation for an hour and i don’t understand most of what anyone said
:D
Jean-Jacques Dubray
@jdubray
Feb 17 2018 15:48
@bsabadach the boundary of a local state is arbitrary, we need to go pass beyond "encapsulation" towards mutate/access rights. The result is the same, but the architecture is more aligned with state representation and functional HTML/view.
You cannot apply V = f(M) when the view contains a stateful component unless the state of that component is folded into the model.
At least, I don't know how to do it.
Paul Reimer
@paulreimer
Feb 17 2018 16:00
I don't mean to distract from the current conversation, but about an hour ago @jannesiera mentioned that Vuex has similar semantics to SAM, and I'm wondering if it is in fact, "SAM-compliant" or can be considered to use the pattern. Does Vuex' design lack anything that SAM can account for?
VaseJS
@VaseJS
Feb 17 2018 16:04
can we define “SAM-compliant” fully first
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:07
@paulreimer Last time I checked it seemed that it didn't have the next-action-predicate but @dagatsoin mentioned some time ago that it was easy to add. Otherwise, I would say it supports the same roles and responsibilities with respect to action, mutation and state representation.
Paul Reimer
@paulreimer
Feb 17 2018 16:08
fair enough, let's say having "SAM semantics" but not necessarily "SAM syntax". and at least the same decoupling in the places that SAM requires
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:11
The way I view SAM compliance is:
  • your code is designed to mutate state in well defined "steps"
  • actions are responsible for translating an event/intent into a proposal to mutate the application state
  • the application state is solely accessible and mutable by the model
  • once the model has completed the mutation it triggers the computation of one or more state representations which are made available to anyone who subscribes to it.
  • the next-action-predicates checks if any automatic action need to be triggered in this particular state and if yes, does so.
VaseJS
@VaseJS
Feb 17 2018 16:12
a definition! now we can continue with the term “SAM-compliant"
Paul Reimer
@paulreimer
Feb 17 2018 16:13
save that post! quite helpful.
That's great because now I can evaluate Vuex/docs (or any new software) with that in mind
boris sabadach
@bsabadach
Feb 17 2018 16:16
@jdubray cool! It took me time to understand that / so when you mention view model what do u mean?
VaseJS
@VaseJS
Feb 17 2018 16:16
in these types of conversations, we must define everything
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:16
:+1:
@bsabadach ? sorry I don't understand the question.
VaseJS
@VaseJS
Feb 17 2018 16:17
what is the view model? is that what you’re asking @bsabadach
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:17
where did I mention the view model?
boris sabadach
@bsabadach
Feb 17 2018 16:18
In your formula on the Sam page
VaseJS
@VaseJS
Feb 17 2018 16:18
@bsabadach can you post the section here so we’re on the same page
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:19
I see
V = f(M) is not really how it works, this is just a convenient way to illustrate the functional HTML paradigm
It's not a good idea to couple the model to the view components
For view components to be reusable across apps or views, they need to use their own "model" (aka props). But that model/these props can be factored as functions vm() which you can call view-model.
boris sabadach
@bsabadach
Feb 17 2018 16:21
V = State( vm(Model.present(Action(data))), nap(Model) )
VaseJS
@VaseJS
Feb 17 2018 16:21
@bsabadach :+1:
boris sabadach
@bsabadach
Feb 17 2018 16:22
@jdubray this not what I understood in this formula
VaseJS
@VaseJS
Feb 17 2018 16:23
i’d propose that V=f(M) should be removed from the site than because it only introduces confusion
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:24
For instance you would have a component
const temp = (temperature, unit = 'C') => `room temperature: ${temperature} ${unit}`
boris sabadach
@bsabadach
Feb 17 2018 16:28
@jdubray ok but what is the vm is this code?
Daniel Neveux
@dagatsoin
Feb 17 2018 16:28
Also a viewModel is what a State function can generate.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:28
one second
Daniel Neveux
@dagatsoin
Feb 17 2018 16:30
A state function can generate anything that is usefull for your app. It can be some html, a plain object (a viewModel), some opengl commands...
boris sabadach
@bsabadach
Feb 17 2018 16:32
I konw that there are many interpretation of VM, one from form MVVM. For me it references the original pattern that was after popularized by microsoft as View model: https://martinfowler.com/eaaDev/PresentationModel.html
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:36
the vm() function is just something like
const vmtemp = (model) => model.room[1]temperature
Daniel Neveux
@dagatsoin
Feb 17 2018 16:36
Don't really know. It could be a class or plain object or what ever can be handle by your State function and passed to the renderer.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:37
then in the state function:
stateRepresentation = {
      temperature: temp(vmtemp(model))
      ...
}
nothing magic, just code factoring to decouple the model from the view
boris sabadach
@bsabadach
Feb 17 2018 16:41
@jdubray well it’s not a detail! That means that the state is a pure representation of the vm (presentation layer) and not the model (domain layer) .I think this the first time I see you writing this.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:43
??
vm's purpose is just to slice and dice the model into props.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:48
.the state function is responsible for decoupling the View/State representation from the Model. The input to the state function is the model. vm() is just a helper function to reuse the mapping model/props.
Daniel Neveux
@dagatsoin
Feb 17 2018 16:49
Mmm, @bsabadach I am pretty sure that V=f(M) means that the state/view/viewmodel/what ever is generated by the State function IS a pure representation of the model.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:49
One of the major pain points in front-end architecture is data-binding. The whole purpose of SAM is to shield application logic from data binding. Everything that achieves that goal is a good thing.
Daniel Neveux
@dagatsoin
Feb 17 2018 16:50
What you do with this representation is outside the context of the pattern.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:51
Correct, SAM stops at the state representation which can be anything you want, as I mentioned above in the fishing game, I even user a higher order function as an element of the state representation.
boris sabadach
@bsabadach
Feb 17 2018 16:52
ok but i think it should be renamed because it’s not what the majority of front dev understand with vm. in MVVM, VM is an abstraction of view and propose an API for the view to work : properties, dynamic styles (no ternary operators in view for styles), predicates for displaying controls 'showThisButton()' and even methods to trigger actions (see the Vue.js component implementation). I’m ok for another definition but it has to be clarified
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:53
The state representation provides a view of the model that is understandable by its consumers. This helps keeping the model to mutation code and nothing else. From a temporal logic perspective it also helps separate computed values (automatic mutations) from mutations.
Mutations are a function of property values from step N-1 and step N, while computed values are only a function of property values at step N.
Daniel Neveux
@dagatsoin
Feb 17 2018 16:55
I struggled a lot in my engine to effectivemy name V.
I tried Derivate but... too mathematical.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:55
For Web Apps, there is also a whole spectrum of possible implementations.
Daniel Neveux
@dagatsoin
Feb 17 2018 16:55
Note that Mobx State Tree called all derivation of the tree a View too. Either it is a plain object or some HTML
boris sabadach
@bsabadach
Feb 17 2018 16:56
ok but I’m sorry to insist a 'view of the model' is not the 'view model'.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:56
you are absolutely correct
boris sabadach
@bsabadach
Feb 17 2018 16:56
@dagatsoin I know but it never talks about view model
Daniel Neveux
@dagatsoin
Feb 17 2018 16:57
Yep, but it can generate a ViewModel if you need it. As you have the hand on the computed function.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 16:58
what I meant by vm() was exactly what I explained above which I believe is related to MVVM in the sense that the props are the structure of the view-model (MVVM).
Daniel Neveux
@dagatsoin
Feb 17 2018 16:59
It is right it that the confusion could be there for people with strong knowledge with this semantic.
For me a viewModel is between the model ans the view to hide some value. Eg in MMORPG we don't need to know about other people inventory.
boris sabadach
@bsabadach
Feb 17 2018 17:05
Capture d’écran 2018-02-17 à 18.02.17.png
@dagatsoin we have to agree on the semantics :
Jean-Jacques Dubray
@jdubray
Feb 17 2018 17:07
@bsabadach you are absolutely correct and this deserves clarification vm() is only the model structure of the view-model, nothing else.
boris sabadach
@bsabadach
Feb 17 2018 17:09
@jdubray I understand now but I usually used to call it model for the view to not interfere with the design pattern
Daniel Neveux
@dagatsoin
Feb 17 2018 17:09
Thax @bsabadach I will read this.
boris sabadach
@bsabadach
Feb 17 2018 17:10
@dagatsoin u’r welcome
Jean-Jacques Dubray
@jdubray
Feb 17 2018 17:13
I am adding the clarification right now, though SAM makes no assumptions on where the actions reside. So this topology is not (totally) incompatible with SAM.
Daniel Neveux
@dagatsoin
Feb 17 2018 17:17
In a sens MVVM could be doable with SAM.
The VM is a class maintained by the State function.
Also the VM transform event from the view into actions.
I don't see use case though.
In a sense MVVM is doable with SAM. It is just a class instance maintained by the State Function. I don't see any use case though.
boris sabadach
@bsabadach
Feb 17 2018 17:20
@jdubray I don’t say this is undoable but never saw an example of it, and was really confused due to my everyday practices and semantics
Jean-Jacques Dubray
@jdubray
Feb 17 2018 17:20

yes, makes sense I added this comment to the site:

The view-model function can be associated to the structure of the model of the view in the MVVM pattern, but in SAM there is no "view state" or "view specific actions". There is a global state and actions which are visible across the entire application.

boris sabadach
@bsabadach
Feb 17 2018 17:21
@jdubray 👍
Daniel Neveux
@dagatsoin
Feb 17 2018 17:34

As your editor is still open, can you put that somewhere? :

The way I view SAM compliance is:

  • your code is designed to mutate state in well defined "steps"
  • actions are responsible for translating an event/intent into a proposal to mutate the application state
  • the application state is solely accessible and mutable by the model
  • once the model has completed the mutation it triggers the computation of one or more state representations which are made available to anyone who subscribes to it.
  • the next-action-predicates checks if any automatic action need to be triggered in this particular state and if yes, does so.
Maybe at the top, in a <h1 style="color: red"> tag :smile:
Jean-Jacques Dubray
@jdubray
Feb 17 2018 17:35
I'd like to think a bit more about it. I am not complete sure it's ok to talk about SAM compliance.
Daniel Neveux
@dagatsoin
Feb 17 2018 17:35
it is the best resume you did
In another room @VaseJS pasted a plan of pattern presentation. It could be veeery usefull too. I don't count people anumore who comes on to the site to find a framework.
in #sam-architecture
devin ivy
@devinivy
Feb 17 2018 18:18
hey @jdubray thinking of vue as an example. it looks like they run mutations directly within actions, which seems like it goes against SAM. just making sure i'm understanding it correctly!
const store = new Vuex.Store({
  state: {
    count: 0
  },
  mutations: {
    increment (state) {
      state.count++
    }
  },
  actions: {
    increment (context) {
      context.commit('increment')
    }
  }
})
it seems like you want the action's proposal broken-up into mutations/acceptors outside of the action.
Daniel Neveux
@dagatsoin
Feb 17 2018 18:28
If you look at your exemple it is just a shortcut to declare the different parts (state, action, mutation). The mutations and the actions are separated.
This example is just a snippet to show all the different part of Vuex. But in a real world app, you will end with a folder for actions and another folder for mutations.
devin ivy
@devinivy
Feb 17 2018 18:34
it's this part i'm wondering about,
  actions: {
    increment (context) {
      context.commit('increment')
    }
  }
it looks like an action calls a mutation directly
Jean-Jacques Dubray
@jdubray
Feb 17 2018 18:34

@devinivy I agree with @dagatsoin from vuex 101:

Mutations are synchronous functions that are used to update state. State must not be updated directly, which means this is incorrect:

yes exactly commit is like "present"
Daniel Neveux
@dagatsoin
Feb 17 2018 18:35
yes commit = present
Jean-Jacques Dubray
@jdubray
Feb 17 2018 18:35
lots of code can go in the action, just like SAM.
devin ivy
@devinivy
Feb 17 2018 18:35
commit sounds more like accept to me
that's my curiosity
Jean-Jacques Dubray
@jdubray
Feb 17 2018 18:35
well, in simplistic scenarios where the mutation always accepts the proposed value, I'd say yes.
But nothing prevents you from having something more complex in the mutation.
Daniel Neveux
@dagatsoin
Feb 17 2018 18:36
@devinivy it could be confusing indeed. But a commit is just a delivery.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 18:36
It's a bit one-to-one, so that's something that hopefully we can go around .
Daniel Neveux
@dagatsoin
Feb 17 2018 18:36
When the delivery man comes to your door, you can still accept/reject the package.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 18:36
:+1:
devin ivy
@devinivy
Feb 17 2018 18:39
in @foxdonut's example earlier you took issue with the fact that actions mapped to an acceptor. if he just named the acceptor "propose" would that really have made it better? that's what this vue example looks like to me.
it seems like there need to be three things,
  1. actions making proposals
  2. proposals being routed to 0, 1, or many acceptors
  3. acceptors performing mutation
in the vue example there are only two places to put code, so by the pigeonhole principle something is being coupled :P
Fred Daoud
@foxdonut
Feb 17 2018 18:45
@bsabadach did you have a chance to look at my example?
@jannesiera is vuex only usable with vue.js?
Daniel Neveux
@dagatsoin
Feb 17 2018 18:46
yes it is a vue plugin.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 18:46
@devinivy well that's why it's important to compare the semantics, not the practices...
Fred Daoud
@foxdonut
Feb 17 2018 18:47
That is a showstopper to me. Meiosis is purposely not tied to any framework.
devin ivy
@devinivy
Feb 17 2018 18:48
@foxdonut i think you could use the vuex store without vue pretty easily if you wanted to https://github.com/vuejs/vuex/blob/dev/test/unit/store.spec.js#L297-L321
Fred Daoud
@foxdonut
Feb 17 2018 18:48
@jdubray I agree with others that your summary of SAM is excellent, sure if you want to think about it a little more, refine it etc. but it will be very valuable to post it on the SAM page. as I mentioned earlier, Meiosis adheres to every point, except for nap().
nap is achievable but not something I have used in the examples.
Daniel Neveux
@dagatsoin
Feb 17 2018 18:49
@devinivy composing mutations is not possible yet. There is an issue about it vuejs/vuex#651
so you are right it is a uncheck point on SAM compliance
Jean-Jacques Dubray
@jdubray
Feb 17 2018 18:51
@foxdonut again, I need to think of it a bit more.
devin ivy
@devinivy
Feb 17 2018 18:51

well that's why it's important to compare the semantics, not the practices...

@jdubray at the end of the day the semantics are here to help us achieve a practice. to factor our code in a reasonable way. if one SAM example is fully correct and the other is fully incorrect simply due to the way variables are named, then to me that means the semantics aren't fully specified enough to help us achieve a healthy practice.

Daniel Neveux
@dagatsoin
Feb 17 2018 18:51
Also there you can compose actions. By using dispatch in another action.
but that break the unit of works principle.
Fred Daoud
@foxdonut
Feb 17 2018 18:51
@devinivy perhaps.. thanks for the info. Nevertheless it is a library, and one of the strengths of Meiosis is that it's not a library, thus does not tie your code to a library specific API.
devin ivy
@devinivy
Feb 17 2018 18:51
@dagatsoin i see! interesting. don't get me wrong, vuex seems nice to me :)
Daniel Neveux
@dagatsoin
Feb 17 2018 18:52
It is the closest implementation of SAM I know
and it is in constant update thx to its author
devin ivy
@devinivy
Feb 17 2018 18:52
yeah, just having a factoring between actions and mutations is huge!
i think that will help folks trying to grapple with how to approach state management.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 18:54
@devinivy you can see that in way too many discussions we are not going to the level of semantics, how can you talk about vuejs/vuex#651 without understanding what it means first?

yeah, just having a factoring between actions and mutations is huge!

yes!

Daniel Neveux
@dagatsoin
Feb 17 2018 18:58
Another library which can be SAM compliant is Mobx. It has the notion of Action, and Transaction. Together, those two things can be used to implement SAM with respect for:
  1. the unit of work
  2. the separation of model/actions/mutations
  3. the overall loop
Jean-Jacques Dubray
@jdubray
Feb 17 2018 19:04
I don't think so, Actions are methods on the model Class, there is no separation between model and action.
Michel feels that the separation between the two leads to code duplication.
devin ivy
@devinivy
Feb 17 2018 19:04

for me understanding whether a code sample matches semantics is first and foremost how the code is factored and how concerns are separated. for me the vuex example and the meiosis example are "isomorphic" to each other because they are factored identically, even though things are named differently. if one isn't true to SAM then it seems neither would the other. the vue example just provides a roundabout way of calling "acceptors" directly from the action acceptor.increment() vs. context.commit('increment'). i'd guess in @foxdonut's example he imagined the acceptors as also being able to reject the proposal just like you're saying vuex's mutations can.

at the end of the day both of those examples require the actions to make each proposal one-to-one with an acceptor, which is an issue of factoring code more so than naming. that's what i thought you originally took issue with in the meiosis example @jdubray.

Jean-Jacques Dubray
@jdubray
Feb 17 2018 19:06
well, it seems that both are using the same practice since @foxdonut is able to modify the sample to match the semantics of the SAM pattern.
devin ivy
@devinivy
Feb 17 2018 19:06
but if that's not critical to SAM, then i may have been misinterpreting your thoughts before!
okay, i see what you're saying! so the issue was only with naming, and not with the one-to-one coupling between proposal and mutation?
Jean-Jacques Dubray
@jdubray
Feb 17 2018 19:08
Nothing is 100% critical, practices can be developed to solve specific problems where the one-to-many relationship is not needed. The problem I have is when a particular approach does not allow me to implement the full semantics. Just like in Redux, nothing prevents someone to implement the SAM semantics, it's just the practices are different.
boris sabadach
@bsabadach
Feb 17 2018 19:08
@foxdonut yes I did but it’s 8PM staurday eve here… I’ll tell you tomorrow if you are aound or later
Jean-Jacques Dubray
@jdubray
Feb 17 2018 19:08
In MobX, I would argue the semantics are different, it's not a full question of practice, since the action has direct access to the model property values and mutate these values.
devin ivy
@devinivy
Feb 17 2018 19:08
@jdubray thanks for your thoughts!
Jean-Jacques Dubray
@jdubray
Feb 17 2018 19:08
thank you!
Daniel Neveux
@dagatsoin
Feb 17 2018 19:20
@jdubray nope, action can be used for function too. I think you refer to the decorator, which is just a wrapper.
I already implemented a nearly SAMish loop with mobx
without class.
Daniel Neveux
@dagatsoin
Feb 17 2018 19:40
And I would argue mobx HAS the same semantics. As it is a low level library it won't prevent you to mutate the model anywhere if you want.
If you go deeper in mobx you will see that Action wrap Transaction. And it is in a transaction which grant the unit of work that the mutation is made.
Daniel Neveux
@dagatsoin
Feb 17 2018 20:06
So when you write your code, the acceptor is wrote using Transaction(fn) and actions Actions(fn)
and for the record, Michel is for separating both: https://github.com/mobxjs/mobx/issues/1139#issuecomment-323071959
VaseJS
@VaseJS
Feb 17 2018 20:12
there is way to much arguing in here. even if you all come to a concensus, how has that improved SAM in the end? As others have mentioned, semantics and naming are important. They should not be taken lightly. Like good code, naming should be consistent and its not. Pick a definition and stick with it regardless of how other people want to define it (unless there is already a solid definition being used). More code, less arguing about the definition of words/terms (because that’s whats been happening for 80% of this conversation)
Jean-Jacques Dubray
@jdubray
Feb 17 2018 20:30
@dagatsoin yes, you are correct, I forgot about that. I was just disappointed to see actions as methods of the model and focused on that.
@VaseJS this is the group of all-timers. We are used to this healthy debates. They keep me honest.
I welcome well tuned BS detectors. That's how we make progress.
VaseJS
@VaseJS
Feb 17 2018 20:33
there is no issue with that, but how is that moving SAM forward if its a community thing (no matter how small we are)? If the arguments are followed up with code to prove each sides point, then we’re moving forward, otherwise, it seems like a waste (though not all arguments need code)
Jean-Jacques Dubray
@jdubray
Feb 17 2018 20:34
they are generally followed by code, we just have been arguing these points for a while so we can get to an agreement without too much code. In the case of Meiosis, I felt it was important precisely because there was a disconnect, we uncovered the disconnect.
VaseJS
@VaseJS
Feb 17 2018 20:35
are these discoveries documented so other don’t come to the same conclusions and the communication surrounding SAM becomes more clear?
this understanding is in a vacuum of the gitter channel
Jean-Jacques Dubray
@jdubray
Feb 17 2018 20:42
no sorry,
that's the essence of the gitter channel Q&A
Daniel Neveux
@dagatsoin
Feb 17 2018 20:49
this last day of exchange was rich on several points. The way you need to be chalanged can be noisy for people that are not used to. Maybe it is time to rethink the website and the approach. It is up to you to decide @jdubray but I think we are enough to help you this way.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 20:53
at the moment I have a couple other priorities, I am having trouble to find the time to finish the stateful component code sample.
I certainly appreciate the discussions, but it's difficult to synthetize everything.
Daniel Neveux
@dagatsoin
Feb 17 2018 20:56
Maybe we can help on that. For exemple, if we take the plan of pattern presentation of @VaseJS I think we can write something with several hands on github and wait for your approval.
There is a lot of energy here. It just misses a channel.
VaseJS
@VaseJS
Feb 17 2018 20:57
@dagatsoin i like that idea
Jean-Jacques Dubray
@jdubray
Feb 17 2018 20:57
Sure, I can use some help.
Paul Reimer
@paulreimer
Feb 17 2018 21:01
It just occurred to me that another way to clarify SAM could be a list of approaches that are "SAM, but..." (in the same way there is the term "Scrum, but..."). E.g. if there was a comparison section that said something like "Vuex is SAM, but... there is no next-action-predicate, Model is named Mutations, and State is called Getter(s)"
(just a collection of observations like that, which could be a moving target, but could also help when comparing frameworks/approaches.)
VaseJS
@VaseJS
Feb 17 2018 21:03
@paulreimer i would say this mainly adds confusion because what its saying underneath it all is that SAM can’t stand on its own. And for people who don’t use other tools like Vue or Re*, it adds noise to the the conversation. if you know Vue, or anything else, the raw code and concepts should seem similar to you anyway
Jean-Jacques Dubray
@jdubray
Feb 17 2018 21:04
It would also get outdated pretty fast. All these libraries evolve at light speed and two month later the information provided is no longer true.
VaseJS
@VaseJS
Feb 17 2018 21:05
patterns do not talk about other tools when written. the observer pattern doesn’t talk about angular or the like. The command pattern doesn’t talk about Express.js or the like. there is enough to understand without the extra noise. However, with that said, it can be done but will take more work to not add confusion
@jdubray my point exactly
Jean-Jacques Dubray
@jdubray
Feb 17 2018 21:06
yes!
VaseJS
@VaseJS
Feb 17 2018 21:06
vanilla JS and explain. that’s all thats needed. and after those frameworks die (because they will), you now have an outdated site
as many years as it has been, the command pattern is not outdated because they did not compare it to a tool for understanding
Jean-Jacques Dubray
@jdubray
Feb 17 2018 21:07
it's just there is a fine line in this case considering how important that space is. People are interested to know if it can help them in their day-to-day job.
VaseJS
@VaseJS
Feb 17 2018 21:07
compare patterns no patterns and principles, not tools
Paul Reimer
@paulreimer
Feb 17 2018 21:07
Yeah, I think it is outside the context of any one framework/pattern anyway (maybe a separate single-purpose site). I am surprised that there is no page that compares frameworks&patterns based on their semantics. I mean in a feature matrix sense regarding the design approach. Eg. a checkbox for "separation between model and view" might be common (most MVC), a checkbox for "separation between proposal and commit" might be more rare (SAM has it, for example).
VaseJS
@VaseJS
Feb 17 2018 21:07
i agree. if they don’t understand patterns and how it can help them in their job, thats their issue truly
@paulreimer they have something but not like what you’re talking about. that would take a group effort or one person with a lot of framework experience!
Jean-Jacques Dubray
@jdubray
Feb 17 2018 21:09
@paulreimer actually MVC tends to promote data-binding and that's what creates the view-model coupling. In theory there is no coupling, in practice, as a real software engineering practice developers demand data binding.
So it's very difficult to dissociate the patter from the framework from the practice of using the framework.
VaseJS
@VaseJS
Feb 17 2018 21:10

I’ve been trying to say that this whole time

So it's very difficult to dissocite the patter from the framework from the practice of using the framework.

Jean-Jacques Dubray
@jdubray
Feb 17 2018 21:10
Unfortunately people are looking for recipes that they will learn and apply over and over.
Paul Reimer
@paulreimer
Feb 17 2018 21:11
Remember I'm a C++ developer integrating SAM pattern into an embedded platform, so I am only seeing the patterns here (JS frameworks can't help me, anyway). But when comparing the patterns, there's not much of a top-level view. The JS ecosystem just has the majority of devs concerned with state mgmt working on the problem, so honestly you are the furthest along (maybe Erlang, not quite applicable to me though)
VaseJS
@VaseJS
Feb 17 2018 21:12
a true pattern is language agnostic.
Jean-Jacques Dubray
@jdubray
Feb 17 2018 21:12
@paulreimer I certainly with I could pair program with you, I spent 10 years of my career building embedded systems and it feels like SAM can provide major advances in that space.
Paul Reimer
@paulreimer
Feb 17 2018 21:12
but it is really hard to extract the CS knowledge back out of the JS ecosystem and to apply it elsewhere (IMO simply because of the framework problem mentioned, they are making it too easy).
Jean-Jacques Dubray
@jdubray
Feb 17 2018 21:13
Last year I was doing a front-end project for a startup here in Bellevue, they had a big embedded component but they declined to look at SAM.
VaseJS
@VaseJS
Feb 17 2018 21:13
@paulreimer too easy is an understatement
Paul Reimer
@paulreimer
Feb 17 2018 21:14
And it seems so competitive in JS, so sometimes it's just unfair bashing or a popularity contest, or a battle of the big tech titans.
VaseJS
@VaseJS
Feb 17 2018 21:14
i can’t have a conversation about anything without someone bringing up a framework
Daniel Neveux
@dagatsoin
Feb 17 2018 21:14
Don't compare framework with SAM ok. But what about people who don't use Vanilla JS?
If we rework the whole communication, we need to specify a target audiance. Vannilla.js is ok for me of we write for lead dev for example. It could be a good start.
VaseJS
@VaseJS
Feb 17 2018 21:14
vanilla is the best just like many of the other patterns are written in C
this one is just JS
but i can read C though i’ve never written a line of it. the same should be true with JS. but if not, someone can write a C version also
Paul Reimer
@paulreimer
Feb 17 2018 21:15
I can see the case that Dr. Lamport is making... this is semantics and patterns beyond any specific language.
VaseJS
@VaseJS
Feb 17 2018 21:16
but the problem, if we look at TLA is that C has brainwashed many people.
@paulreimer ha, we’re on the same page
Daniel Neveux
@dagatsoin
Feb 17 2018 21:17
And as @paulreimer which write on C is not interested in JS.
Maybe we can reach a broader audiance of lead dev by wrote example on different language (with a tab to switch between)
VaseJS
@VaseJS
Feb 17 2018 21:17
the lang is not as important as how it works. i believe using math would deter people. A language has to be picked and it happens to be JS this time instead of C
@dagatsoin exactly
Paul Reimer
@paulreimer
Feb 17 2018 21:17
BUT still, where is the comparison of the other approaches, as they are? The GoF book is helpful but there's lots of new patterns since then! Do we need an awesome-patterns?
VaseJS
@VaseJS
Feb 17 2018 21:18
@paulreimer the format of patterns have not changed though. they still have to answer certain questions and the GoF is still relavent to this day!
Daniel Neveux
@dagatsoin
Feb 17 2018 21:18
(What more recent book dobuoi advice. I loved so much the GoF)
Paul Reimer
@paulreimer
Feb 17 2018 21:19
Oh yes, I use them all the time. But for example, observer -> observable is a huge deal. [and not covered by GoF]
VaseJS
@VaseJS
Feb 17 2018 21:19
as long as they follow principles, the pattern is sound. but only in theory until it has been used in non-trivial projects. that has yet to be done to the best of my knowledge
Paul Reimer
@paulreimer
Feb 17 2018 21:20
IMO the concept of mutations (in the context of SAM/Vuex) is also a huge deal
VaseJS
@VaseJS
Feb 17 2018 21:20

@dagatsoin >dobuoi

???

Daniel Neveux
@dagatsoin
Feb 17 2018 21:21
Sorry I am on mobile and it is a nightmare to type... I meant "what more recent book do you advice?"
VaseJS
@VaseJS
Feb 17 2018 21:22
@dagatsoin exactly. Most books are just reusing the same patterns of the GoF. There are some people who are proposing now patterns, but that doesn’t change the life cycle of a pattern. it still must go through its trail period
when MVC came out with Smalltalk, it was a huge deal too! after being use in non-trival projects, it passed the test and is still used (though incorrectly) today
SAM is young, but it should not make young mistakes like thinking it can short-cut the pattern making process. so until then, follow the pattern (pun intended) ;P
devin ivy
@devinivy
Feb 17 2018 21:29
it is also a bit more involved/nuanced than your average pattern, i think.
for example, you could use many patterns from the GoF to help implement SAM. it really is more of a protocol/semantics.
VaseJS
@VaseJS
Feb 17 2018 21:30
@devinivy definitely.
then maybe pattern is the wrong term, but it seems like a pattern still
devin ivy
@devinivy
Feb 17 2018 21:30
yeah, i definitely appreciate the term! i'm just trying to figure-out how it fits with other such patterns.
VaseJS
@VaseJS
Feb 17 2018 21:31
we need some UML diagrams, and answers to some specific pattern questions answered very clearly on the site.
to follow tradition
devin ivy
@devinivy
Feb 17 2018 21:32
andre staltz once called these things "architectures"
the types of details that he uses in that article would be useful to apply to SAM
VaseJS
@VaseJS
Feb 17 2018 21:33
architecture may be a better word
but those are still patterns too
structure patterns
Daniel Neveux
@dagatsoin
Feb 17 2018 21:51
We need to set a target audiance before. Not to small but reachable with our ressources. (More details ask for more time)
What typical developper can we talk to easily ?
It is important as this will lead all our discords 😀
devin ivy
@devinivy
Feb 17 2018 21:56
it seems natural to talk to developers building stateful web interfaces. any vue, react, polymer, angular, choo developer who cares about building maintainable interfaces would count!
Fred Daoud
@foxdonut
Feb 17 2018 22:01
@bsabadach sure I understand, if you reply here whenever you have the chance, and @ mention me, I will certainly read it. Thanks in advance.
@jdubray I have updated the example to call Model.present from the actions and here is the Model. There are some ways that may make the code a little better than a series of if/else statements, but I left it like that in the spirit of Vanilla JS for @VaseJS :)