Skip to main content

Questions tagged [enum]

Enum (also enumeration) is a data type consisting of a set of named values called elements, members or enumerators of the type. The enumerator names are usually identifiers that behave as constants in the language, and are often predefined with an implied ordering.

5 votes
1 answer
337 views

I see this pattern a lot, especially with countries, or more generally regions. An enum is defined with additional fields and with methods that translate to and from these values. Example: import ...
user2740's user avatar
  • 159
3 votes
3 answers
317 views

I am working on a C# project and I have a somewhat large number of labels (~100) that have some sort of relationships between one another. Here is a minimal dummy example that illustrates this: ...
evolved_antenna's user avatar
2 votes
1 answer
135 views

I will get to the question in a minute.... We have 2 in house services that either have an API contract between the 2 that involves an enum or the enum value is stored in a shared database. I don't ...
jdtommy's user avatar
  • 129
2 votes
1 answer
674 views

Although I love Rust's enums (and the idea of making illegal states unrepresentable), I'm struggling to represent (ironic, yes) them in databases like PostgreSQL when the variants have data associated ...
yoshke's user avatar
  • 29
0 votes
3 answers
8k views

I can write an enum with properties besides the name and ordinal. A very generic example would be: public enum ExampleEnum { EXAMPLE0(Example.example0), EXAMPLE1(Example.example1), ...
CPlus's user avatar
  • 1,219
5 votes
6 answers
4k views

Over the years I've many times seen folks enumerate error codes for exceptions in Java. I generally have felt this leads to more tedious code and does not provide value. For example, there will be an ...
Kirby's user avatar
  • 271
2 votes
1 answer
872 views

In the simplest case, I have some code where the user may want to do one thing (a), another thing, (b), or both (a+b). The options are reasonably complex and have their own functions, but I would like ...
QuantumChris's user avatar
3 votes
2 answers
412 views

I have seen in mainly high level languages, but also in lower level languages, the use of option names as strings to specify one of several fixed options, or as flags, or more generally, code using ...
CPlus's user avatar
  • 1,219
0 votes
3 answers
3k views

I have built a string to enum converter, which converts a known set of strings that it receives into enum, in order to satisfy a function pointer. Some of you may recognize some elements of this ...
HFOrangefish's user avatar
2 votes
1 answer
4k views

I have a class that I use to define different types of plots I am performing class MyPlots(Enum): STANDARDSCALE = "standard" LOGSCALE = "log" there are default values ...
La Cartuccia's user avatar
2 votes
3 answers
1k views

I have seen a common design pattern where there will be a "lookup table" in the database like this: Color ColorId ColorName 1 Blue 2 Red 3 Green with a foreign key constraint on other tables,...
JoelFan's user avatar
  • 7,151
-4 votes
1 answer
171 views

I'm currently reading Code Complete by Steve McConnell. In section 12.6, Enumerated Types, he says that we can define first and last entries like limits: Define the first and last entries of an ...
CoderDesu's user avatar
  • 1,015
1 vote
2 answers
1k views

I am practicing design patterns and OO concepts such as inheritance in java and I'm writing an application that represents a vending machine. I have two questions focused on ideal structure and design ...
Bob Jones's user avatar
6 votes
3 answers
7k views

This question considers whether SQL DB data should be represented as an enum or by a reference table, when the application code is aware of particular instances of said data. I'll illustrate with an ...
Moeghoeg's user avatar
3 votes
4 answers
2k views

The project I'm working on has a code dependency on a TeamNames enum. The problem with this is that the project needs to be recompiled and redeployed on any addition/deletion in TeamNames. How can I ...
NiceOne's user avatar
  • 33

15 30 50 per page
1
2 3 4 5
9