These are chat archives for jdubray/sam

11th
Jun 2017
Michael Terry
@formido
Jun 11 2017 20:03
Let's say your model is an array of names
in the UI you want to present them in sorted order
your action wants to add a name
should the action be given the model to do the sorting?
should the model sort the names?
or should the state representation sort them
or is this a matter of efficiency trade-offs, so it depends
any rationale for one or the other
the action shouldn't get the model of course
but if there's a lot of name sorting every time in the state representation would be inefficient
I'm leaning toward the model
is that a core function of the model in your mind?
Jean-Jacques Dubray
@jdubray
Jun 11 2017 21:14
I think that's a state representation or event the view's responsibility. For instance DataTables allow you to sort on the spot, there is no reason the model should sort them out. For efficiency you might do that in the state function (if the sort is required in different places or the view is not capable of doing it, or you want to start the view in a specific order).
Michael Terry
@formido
Jun 11 2017 21:14
good point
yep
Jean-Jacques Dubray
@jdubray
Jun 11 2017 21:15
yes, if the dataset is big and makes the whole process inefficient, you could still do it in the model, but in general that's not the correct location.
Michael Terry
@formido
Jun 11 2017 21:16
yeah, the DataTables analogy was a good one