Created
May 2, 2022 10:30
-
-
Save tuanpmt/d3c9c2bf610c72184d62fa03c2194ae8 to your computer and use it in GitHub Desktop.
STATELESS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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