[개념] stateful vs stateless ..
ITWeb/개발일반 2016. 2. 25. 14:19stateful 과 stateless 라는 말이 나오는데.. 찾아 보면 튜링이 어쩌고 람다가 어쩌고 나옵니다.
그리고 상태를 저장하고 저장하지 않고 뭐 그렇다는데요.
초간단하게 정리된 내용을 발견해서 기록해 봅니다.
Stateless - There's no memory (state) that's maintained by the program
Stateful - The program has a memory (state)
To illustrate the concept of state I'll define a function which is stateful and one which is stateless
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;
}