Custom Enumeration vs Constants
Developers should use custom enumeration when they need to define a closed set of related values in their code, such as for representing states (e meets developers should use constants to define values that remain unchanged throughout a program, such as mathematical constants (e. Here's our take.
Custom Enumeration
Developers should use custom enumeration when they need to define a closed set of related values in their code, such as for representing states (e
Custom Enumeration
Nice PickDevelopers should use custom enumeration when they need to define a closed set of related values in their code, such as for representing states (e
Pros
- +g
- +Related to: type-safety, data-structures
Cons
- -Specific tradeoffs depend on your use case
Constants
Developers should use constants to define values that remain unchanged throughout a program, such as mathematical constants (e
Pros
- +g
- +Related to: variables, data-types
Cons
- -Specific tradeoffs depend on your use case
The Verdict
Use Custom Enumeration if: You want g and can live with specific tradeoffs depend on your use case.
Use Constants if: You prioritize g over what Custom Enumeration offers.
Developers should use custom enumeration when they need to define a closed set of related values in their code, such as for representing states (e
Disagree with our pick? nice@nicepick.dev