Skip to content

Instantly share code, notes, and snippets.

@tuanpmt
Created May 2, 2022 10:30
Show Gist options
  • Save tuanpmt/d3c9c2bf610c72184d62fa03c2194ae8 to your computer and use it in GitHub Desktop.
Save tuanpmt/d3c9c2bf610c72184d62fa03c2194ae8 to your computer and use it in GitHub Desktop.
STATELESS
/* GOOD */
// The state is derived by what is passed into the function
function int addOne(int number)
{
return number + 1;
}
/* BAD */
// The state is maintained by the function
private int _number = 0; //initially zero
function int addOne()
{
_number++;
return _number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment