These are chat archives for jdubray/sam

1st
Nov 2017
Paolo Furini
@pfurini
Nov 01 2017 12:33
@jdubray hi, regarding the async operation above in the querySmthAction, that's ok until several async operations start to overlap/collide with data streams coming from the user for example.. that's where tutorials fails 99% of the time, because they always concentrate on the "happy path", and not on the real-world challenges
beside using pub/sub mechanisms to ensure some ordering, maybe also mechanisms like "backpressure" ones can help in this regard (https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/backpressure.md)
Jean-Jacques Dubray
@jdubray
Nov 01 2017 12:46
No, I don't think this is correct.
That's really the beauty of decoupling the action (and its streams of data) from the mutating the state, from the decision of rendering. Once these three aspects are decoupled, it's much easier to code. IMHO, it's worse to rely on a generally defined schemes.
Paolo Furini
@pfurini
Nov 01 2017 12:52
but when async operations are involved, there's always the problem of ordering the effects
if order is irrelevant, that's not even a problem, but that's not always the case
Paolo Furini
@pfurini
Nov 01 2017 12:57

IMHO, it's worse to rely on a generally defined schemes.

ONE universal scheme, I agree, but some pre-defined patterns/architectures for different use-cases are needed when you (I) want to build some reference code to be used by less experienced devs

Regarding spreading API calls in different "layers" or "block types".. I'm not sure of long-term maintenance burden
Victor Noël
@victornoel
Nov 01 2017 13:16
@pfurini while I agree with what you say about 99% of the tutorials and the fact that there is an open question with async operations, I'm not sure pub/sub would solve the problem at all, in terms of execution, that's the same thing as having multiple async operations being executed: at one point you need to reconcile all of it at the model level (for example). SAM would say that it is the model responsibility of being coherent with respect to all the async operations.
Jean-Jacques Dubray
@jdubray
Nov 01 2017 13:24
@pfurini I am not sure the ordering of data streams have a gerenal, even pattern based solution. The model would let you adopt any strategy that is relevant to your solution. That's precisely the problem I see with so called "reactive" approaches, the logic is coupled to the stream. That cannot work very well when you have more than one stream.
Of course, the order of events itself has a general solution, but what I mean is deciding how you render the streams of data where some streams may be more choppy than others, then you have to make ad hoc decisions with the chunks of data that you are getting (render, wait, discard).
Paolo Furini
@pfurini
Nov 01 2017 15:08
logic is coupled with the stream if you program them so.. u can even build the entire SAM loop using streams, when coupled with dynamic code that selects the right logic at a given point (for example u can select an action based on some intent data, using an ActionResolverService)
I always struggle to find the most generalized solution to a problem, because only with that I can really build reusable code, and in the end build a team culture around it
Paolo Furini
@pfurini
Nov 01 2017 15:15
generalized solutions can be documented more easily, and even if they never cover 100% of use cases (never seen such a coverage in my entire life, anyway), they are always more useful than a collection of guidelines and unrelated pieces of code
where a generalization is not possible, leave a hole with 2, 3 or more alternatives to choose from, but never leave it too open.. I'm speaking of giving clear guidance to newcomers, as they need a path to follow, or they'll be lost in no time. Speaking of paths, it's better to give only a small number of alternative ones, instead of saying "you're free to do whatever you want here", or, again, they'll be lost sooner than later
Victor Noël
@victornoel
Nov 01 2017 15:34
I think we all agree on that :) but saying "we use stream" or "we use pubsub" is not a generalized documented solution. At one point you have to say "api calls goes there, shared data here, modification of shared data always goes there under these conditions, etc", whatever is the technological pattern you use (stream, pub/sub).
so yes, you need to instantiate SAM (for example) with a given technology, and then make that an architectural style that has to be followed throughout the whole application by the team
scratch that, it should be: you need to instatiate SAM (for example) with a given technology, and then make that an architecture that has to be followed throughout the whole application by the team (sam is the architectural style ;)
Paolo Furini
@pfurini
Nov 01 2017 15:42
We're on the same page :) regarding the angular 4 sample, is there some high level documentation on the chosen SAM implementation?
I see the overall picture, but looking at the code there seems to be some unused stuff here and there.. I'd like to read about the decisions made in writing that sample
Jean-Jacques Dubray
@jdubray
Nov 01 2017 16:14
I probably need to do a major cleanup, but the choice I made originally was to use a pub/sub mechanism to render the State Representation. The major drawback of this decision is that you have to decide what changed in the state representation, at the same time, since Angular is template based, I don't feel there was/will be a much better solution (compared to functional HTML based approaches).
Other than that, everything else is pretty much standard SAM. I am certain there might be a more elegant implementation using the full power of TypeScript, and Angular's architecture, but as you know, I am very sceptical about the future of Frameworks and the least I can use/rely on, the better.
Victor Noël
@victornoel
Nov 01 2017 16:22
yep, I worked a bit at cleaning the angular 4 sample. It's basically typical SAM except for the state that is expressed in terms of observable selectors on the model if I remember right
I still plan one day to manage to instantiate a SAM like architecture in a real angular app, but never got around it. I only used angular 2+ in my frontend developer experience, second big app I'm working on right now, there is no store/ngrx/redux yet, so I will maybe bit by bit introduce SAM concepts but I'm not alone in the team, I'm not sure how successful I will be :)
Paolo Furini
@pfurini
Nov 01 2017 16:34
OT: it'd be nice to port angular/react samples to https://stackblitz.com/, for fun and easy experimentation ;)
Fred Daoud
@foxdonut
Nov 01 2017 16:38
@pfurini that's cool! it looks to me similar to https://codesandbox.io/, do you know if there are significant differences?
now also for ionic.. it's simply wonderful
one test to rule them all: try to load https://github.com/gothinkster/realworld
the culprit is in the template.builder.ts file in this plunker: http://plnkr.co/edit/wh4VJG?p=preview
it is a convoluted way to compile dynamic templates off of a function, hence achieving the same V=f(M) as in react
Paolo Furini
@pfurini
Nov 01 2017 16:55
TBH, the amount of boilerplate code needed to run this sample is simply overwhelming 8-/
Jean-Jacques Dubray
@jdubray
Nov 01 2017 16:57
@pfurini I tried before, using a version of Angular2 (beta 4?). It works but it's too much of a twist for regular Angular developers.
The pub/sub mechanism seems good enough (from experience)
Paolo Furini
@pfurini
Nov 01 2017 17:02
@jdubray agree, it's something that could be useful in some cases though.. after going through the code, it all makes sense, but it leaves asking: angular team, there were really no SIMPLER ways to achieve the same result? ...
Jean-Jacques Dubray
@jdubray
Nov 01 2017 17:02
Agreed, I have the same sentiment.
IMHO, this is the case because Angular is trying to own every aspect of the app, including business logic. That is the problem. You can see the same thing happening with Stencil.js
On another note, after playing with Web Components, I feel they are a nice addition, as long as you build "components" with them. They can help with the desired outcome of a functional HTML architecture.
In SAM it would simplify the "theme.js" aspects, though I would not replace it entirely with Web Components.
Paolo Furini
@pfurini
Nov 01 2017 17:05
so have you tried the stencil compiler from ionic?
Jean-Jacques Dubray
@jdubray
Nov 01 2017 17:06
I just looked into the docs, so far and ran the news sample app.
I have to spend more time to investigate it
Paolo Furini
@pfurini
Nov 01 2017 17:07
I wish I had more time for this.. I only watched a couple of videos and read through the docs
Jean-Jacques Dubray
@jdubray
Nov 01 2017 17:09
it definitely looks nice. So far, I feel good about Service-Workers + Web Components, that's a really nice addition to the SAM pattern. I will produce a sample soon.
Jean-Jacques Dubray
@jdubray
Nov 01 2017 21:20
Angular 5 is out #Konseledise
Holger Winkelmann
@hwinkel
Nov 01 2017 21:28
With Statetransfer between Server and Browser
Jean-Jacques Dubray
@jdubray
Nov 01 2017 22:56
Yes, though I would argue that for Web apps that are not content driven Server-Side rendering is not desirable. Google is also capable of indexing SPAs (client-side rendering)
Paolo Furini
@pfurini
Nov 01 2017 22:58
@jdubray precisely.. for my use cases SS rendering is pretty useless
Jean-Jacques Dubray
@jdubray
Nov 01 2017 23:05
Though here they seem to focus the Transfer State towards an API response cache: https://next.angular.io/api/platform-browser/TransferState
Jean-Jacques Dubray
@jdubray
Nov 01 2017 23:11
The primary use case seems to still be indexing/crawling