uranther

uranther

SAM is a new reactive/functional pattern that simplifies Front-End architectures by clearly separating the business logic from the view and, in particular, strictly decoupling back-end APIs from the Front-End. SAM is technology independent and as such can be used to build Web Apps or Native Apps. It is also protocol independent and can be implemented over HTTP, WebSockets…

Creator: @jdubray
Gitter chat: https://gitter.im/jdubray/sam

SAM is a pattern that aims at replacing the MVC pattern. If you are already familiar with MVC, you should be able to make an easy transition to SAM.

There are two main differences between MVC and SAM. First, SAM is reactive, while MVC is generally implemented in an interactive way. Some attempts have been made at implementing it in a reactive way, however, SAM is not just a reactive implementation of MVC. Second, SAM introduces the concept of State as a mechanism to further decouple the View from the Model and treats the view merely as a “State Representation”.

Articles

Examples

  • sam-tic-tac-toe
  • SAM Lambda — SAM Lambda is a boiler plate project that implements the SAM pattern in AWS Lambda using DynamoDB to manage application/session state

Temporal logic of actions (TLA)

Articles

  • Temporal logic of actions (TLA) is a logic developed by Leslie Lamport, which combines temporal logic with a logic of actions. It is used to describe behaviours of concurrent systems.

  • TLA+

    … is a formal specification language developed by Leslie Lamport. It is used to design, model, document, and verify concurrent systems. TLA+ has been described as exhaustively-testable pseudocode and blueprints for software systems.

    TLA+ is based on the idea that the best way to describe things formally is with simple mathematics, and that a specification language should contain as little as possible beyond what is needed to write simple mathematics precisely. TLA+ is especially well suited for writing high-level specifications of concurrent and distributed systems.

  • Use of Formal Methods at Amazon Web Services

  • Why We Should Build Software Like We Build Houses

INDIRECT

Presentations

Academic Papers

See The Writings of Leslie Lamport for a full list of publications from this researcher.

“Programming languages provide no well-defined notion of a program step”

“State machines provide a framework for much of computer science. They
can be described and manipulated with ordinary, everyday mathematics”

Books

Related architectures

Showing Posts 1 to 10

gregvaughn

gregvaughn

Interesting. This is the first time I heard it called SAM. I first heard about it as the Reactor model, or even “The Elm Architecture”

StefanHoutzager

StefanHoutzager

Because Dubray has some critique on elm and says that an alignment with SAM would make it stronger I posted a question in an elm discussiongroup: Redirecting to Google Groups

jdubray

jdubray

What’s missing in modern frameworks like Elm is the notion of a “Step” you just cannot arbitrarily process events, that is the problem. SAM suggests that a “step” (in response to an event) is composed of three phases: propose, accept and learn. When Elm issues a series of tasks to run some effects, it misses the essence of state mutation.

SAM is based on TLA+ semantics which introduce a new way to look at state machines, a lot closer to the way we write every day code (as opposed to traditional semantics like tuples (S0,A,S1). TLA+ provides enough structure without the burden of traditional state machines.

Happy to continue the discussion if you’d like.

rvirding

rvirding

Creator of Erlang

Shouldn’t the model and the state be one? Which states you have and transitions between them is completely defined by the model so splitting them seems strange.

But I may have misinterpreted the meaning of state and model.

Robert

StefanHoutzager

StefanHoutzager

Mr. Dubray, I would love to get some more explanation about your graphql critique here: Api for an SPA - #4 by benwilson512.
Thanks for joining the discusion (on the elm forum also)!

jdubray

jdubray

I’d prefer if you call me JJ.

Disclaimer, I was one of the original author of the SDO specification (Service Data Object- http://www.oracle.com/technetwork/testcontent/sdo-specification-java-v2-131073.pdf). I also worked for companies like Object Design (Object and XML Database) and built some solutions with products like MetaMatrix (now part of JBoss)

So, I am certain that GraphQL can solve a class of problems. I am sure it does wonders to Facebook because they can align their entire back-end to play nicely with GraphQL but this is not true of everyone. Stitching a complex back-end to GraphQL will always be the problem like it was for SDO or MetaMatrix. The other problem is more fundamental, data is relational and not “navigational”, no matter how you look at it and as soon as you start distributing it, you’ll run into performance issues each time you’ll need to perform joins across system boundaries. There is simply no way around it.

So again, I am certain it works well for Facebook, but it will fail entirely in the enterprise. You just can’t fight the relationality of data.

mkunikow

mkunikow

Ok I agree that GraphQL not always be prefect match. But what about the case you can have full control of backed and you can easy write back end as GraphQL?

Another solution for complex backed is BFF.

Anyway developers are moving away to handle different endpoint REST services in client and prefer to have some simplify/more optimized solutions. Imagine if you have 20 different REST endpoints you need to handle in mobile app. This is nightmare.

For me interesting alternatives to REST:

  • GraphQL/Relay
  • pouchdb <->CouchDB (client read/writes to local database → automatic populated to server database)
  • https://www.firebase.com/ (real time database)
jdubray

jdubray

David Fall has created a SAM sample using FireBase, it’s really good. We are currently discussing it on Gitter

https://github.com/509dave16/sam-tic-tac-toe

gitter.im/jdubray/sam

jdubray

jdubray

Yes, that was exactly the problem I was trying to solve with SAM. This problems comes mainly from templates and databinding (1 API per screen/view)

That being said, weaving API calls in React is a real nightmare, a complete after thought in their programming model.

With SAM, APIs are hidden behind the model and the actions, so that you can use coarse grained APIs, up to direct persistence of the model in a document oriented database. I wrote an AWS Lambda / DynamoDB sample if you want to take a look.

mkunikow

mkunikow

Sure I will check with pleasure :slight_smile:

Where Next? Top

Trending in Wikis Top

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews