Constants vs Custom Enumeration
Developers should use constants to define values that remain unchanged throughout a program, such as mathematical constants (e meets 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. Here's our take.
Constants
Developers should use constants to define values that remain unchanged throughout a program, such as mathematical constants (e
Constants
Nice PickDevelopers 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
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
Pros
- +g
- +Related to: type-safety, data-structures
Cons
- -Specific tradeoffs depend on your use case
The Verdict
Use Constants if: You want g and can live with specific tradeoffs depend on your use case.
Use Custom Enumeration if: You prioritize g over what Constants offers.
Developers should use constants to define values that remain unchanged throughout a program, such as mathematical constants (e
Disagree with our pick? nice@nicepick.dev