Skip to main content


Showing posts from June, 2018

Briefly Stateless and Stateful Design in Programming

Stateless programming is related to the mathematical notion of a function, which when called with the same arguments, always return the same result. This is a key concept of the functional programming paradigm. In other words; Stateless means there is no memory of the past. Every transaction is performed as if it was being done for the very first time. Stateful means there is memory of the past. Previous transactions are remembered and may affect the current transaction. RESTful we services are by design stateless, so is ASP.NET MVC. Stateless: //The state is derived by what is passed into the function function int addOne(int number) { return number + 1; } Stateful: //The state is maintained by the function private int _number = 0; //initially zero function int addOne() { _number++; return _number; }