Index
Example


Let's figure out these important terms called "stateful" and "stateless".

For a simple example where we have a Car (purchase). We need to be able to compute

totalPrice = stickerPrice - discount


A "stateful" model is dependent on other state (data) to compute total price.

The "discount" is not part of the model. Is is external to the model.

It can not independently compute the total price.
A "stateless" model is independent (self-described).

It can independently compute the total price.
What would be a weakness of receiving a stateful model as as part of a web request?


The stateful model would be missing important information. It could not calculate.

In other words the request is incomplete -- we have a mess.
Would a stateless model solve the problem we encountered with the stateful model?

Everything we need is in the request.

Yes indeed.

The stateless model does not need other state/data.