2016/01/07 23:39:06
I was pondering, how does MVC map onto modern paradigms. Say, we abstract from State Monad, from ScalaZ State Monad, just look into it as if.

Easy.
Controller calls Model, passing a callback to View, that's it.
Controller.iWantSomething() {
  Model.giveMeSomething(args, myView:Something => ())
}


So model gets the data and calls the view, that's it.
We don't have to figure out in controller, what was it, and then call view or whatever.
Also, we can parallelize it heavily.

Like in JavaScript, like in AJAX (async version).

It's pretty much a state machine, right? Controller is input, Model is State (monad), View is output.

I know, I know, it's all trivial, kind of.
But so many times we write code that calls something and waits for results and then processes (e.g. visualizes) the results... I'm starting to figure out that it's not beautiful. I mean, at times it is, but frequently it's not.

Alternatively, we can pass two functions, one "onsuccess", another one "onerror". Same as a function on a union, right? Categorically speaking.
76 посетителей, 1 комментарий, 56 ссылок, за 24 часа