Relative Content

Tag Archive for enum

How far should I expose this status enum?

I wrote a little app to manage an arbitrary series of tasks (e.g., call a SQL sproc and capture out-vars, run another app, run an SSIS package) with dependencies between tasks. Each task has a status (waiting to start, failed and waiting to retry, failed and abandoned, succeeded, etc.). Internally, each Task object has a field of the TaskStatus enum type. There’s a TaskManager object which starts tasks and monitors their successes and failures, and a Dashboard WinForm which displays progress.

Is switch-case over enumeration bad practice?

I have an enumeration with the commands Play, Stop and Pause for a media player. In two classes I do a switch-case over the received commands. The player runs in a different thread and I deliver the commands in a command queue to the thread.

Should I create an Enum mapping to my database table

I have a database table containing a list of systems relevant to the tool I am building, mostly in-house applications, or third-party systems we receive data from. This table is added to infrequently, approx every 2 months.

How to deal with almost the same enums?

I need to define enums in several classes. The majority of fields are the same in all of the enums. But one has one or two more fields, another has fewer fields. Now I wonder what is the best way to deal with this?

Keeping an enum and a table in sync

I’m making a program that will post data to a database, and I’ve run into a pattern that I’m sure is familiar: A short table of most-likely (very strongly likely) fixed values that serve as an enum. So suppose the following table called Status:

Do I really want a dynamic Enum, or something else? Better caching? A Struct?

This question is asked on SO and this site often it looks like. “How do I do a dynamic enum?” Answers range from you shouldn’t to possible compile time solutions. Now my question is do I want a dynamic enum that is generated from look up tables in the DB, or do I want something else that is similar?

Is it possible to avoid enormously big switch in that case? [duplicate]

This question already has answers here: Refactoring Switch Statements and is there any real use for Switch Statements at all? (7 answers) Closed 11 years ago. I’m writing a simple chess-related code with intention to write it clearly (performance doesn’t matter at all). And this method I have doesn’t look clean to me at all: […]

Is it possible to avoid enormously big switch in that case? [duplicate]

This question already has answers here: Refactoring Switch Statements and is there any real use for Switch Statements at all? (7 answers) Closed 11 years ago. I’m writing a simple chess-related code with intention to write it clearly (performance doesn’t matter at all). And this method I have doesn’t look clean to me at all: […]