Concept

Why are enumerated types better than arbitrary integer error codes?

ComputerScienceOne / Enumerated Types

"The usage of the integers 1, 2, 3 to indicate the various errors was arbitrary. These are essentially magic numbers that the calling function would have to deal with by making comparisons with various integers. The numbers themselves are meaningless and someone using them would need to constantly refer to documentation to understand which integer corresponded to which error condition. It would be much better if we could follow the strategy of the errno and define human-readable identifiers for each error code. We could accomplish this by defining macros, but another solution is to use an enumerated type."

Related Ideas

Why are enumerated types better than arbitrary integer error codes? | ComputerScienceOne | Bifalgorithm | Bifalgorithm