Skip to content

Instantly share code, notes, and snippets.

@nobitagit
Created August 4, 2016 09:57
Show Gist options
  • Save nobitagit/2f7bdebbc1e17d5ec53dd250ec9ba1b3 to your computer and use it in GitHub Desktop.
Save nobitagit/2f7bdebbc1e17d5ec53dd250ec9ba1b3 to your computer and use it in GitHub Desktop.
Systematic program design in Js - How to design data - Enumeration
/**
* Role is one of:
* - "superAdmin"
* - "admin"
* - "user"
*
* Interp. the role of a registered user
**/
// <examples are redundant for enumerations>
/**
* function fnForRole(role) {
* if (role === "superAdmin") {
* ....
* }
* if (role === "admin") {
* ....
* }
* if (role === "user") {
* ....
* }
* }
*
* Template rules used:
* - one of: 3 cases
* - atomic distinct: "superAdmin"
* - atomic distinct: "admin"
* - atomic distinct: "user"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment