Jan. 7th, 2016

juan_gandhi: (VP)
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.
juan_gandhi: (VP)
"Хлопоты! Началась перестройка на кухне! Старые вещи - вон!"

(А вот что перепечатывал 10 лет назад: "Почему на Майдане было так много людей, почему они все туда вышли? Потому что большинство из них прошло через издевательства — налоговые, над бизнесом, плату государственному рэкету, физические расправы, запугивание перед выборами и т.д. и т.п. Каждый второй там был жертвой этого режима.")

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

August 2025

S M T W T F S
      12
3456789
10 11 12 13141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 16th, 2025 05:38 pm
Powered by Dreamwidth Studios