A data type consisting of a set of named values called elements, members or enumerators of the type.
2
votes
0answers
55 views
SImple wrapper for OpenGL
I am writing a simple wrapper for OpenGL for personal use. Currently I have a gl::Buffer (for VBO, EBO etc...) and it can have several types (...
3
votes
1answer
70 views
Enums for measurement units, with possible circular dependency
I have some enums that define measurement information, such as volume, mass, distance etc...
They are defined as such:
...
3
votes
2answers
83 views
Map enum values
I want to map values of a enum to some other values. For instance, here I map Color to Group:
...
0
votes
3answers
60 views
Mixing business logic and presentation layer in enum type
Let's assume I have an enum type with currency:
...
5
votes
0answers
59 views
Possible class redundancy and improper enum usage
I am looking for code correctness and design usage as I think I might be over doing it in the class department.
There are two things I'm mostly concerned with.
The possible redundancy of classes ...
7
votes
3answers
183 views
Using enum descriptions to string/text binding
In my WP8 application I need to show a couple of radio buttons to let the user select a value out of an enum. I don't want to hardcode either the value or the text ...
3
votes
2answers
98 views
Mapping enum keys to instance values
I am working on a pathfinding program / algorithm, and I have the following class:
...
2
votes
2answers
77 views
Extracting name and value from the enum
I wrote the below enum from which I need to extract the name and its value:
...
-3
votes
2answers
46 views
enum property comparison in if-else structure - How could I generalize this? [closed]
So I have two methods. They do the following.
...
17
votes
2answers
565 views
Enum, constants, or other to represent chess pieces
I'm learning C# and I decided to write a chess program to help me practice the concepts I'm learning in my book. I started the Board class tonight, which is going to handle 1) the board state and 2) ...
13
votes
1answer
290 views
Let's play some Swift Poker
Before you can do any sort of card game, you must first write some code to define your deck of cards.
One thing I've noticed in looking at some of Apple's Swift interfaces is that they very much so ...
1
vote
0answers
62 views
Enum list to STL container, part 2
Original question:
Enum list to STL container
Goal: Write a function enumToSTLContainer() that is to return any STL container whose elements are from a specified ...
2
votes
1answer
64 views
Enum list to STL container
Can someone improve upon this function of mine? EnumToSTLContainer is supposed to make a copy of any STL container whose elements are from a specified ...
2
votes
0answers
83 views
Supporting Enum in EF 5 with .Net 4.0 (Visual Studio 2010)
I'm currently working through Getting Started with EF5 using MVC 4 in Visual Studio 2010 (.NET 4.0) to learn about how to use ASP.NET and Entity Framework. During the beginning of the tutorial I ran ...
8
votes
1answer
218 views
Too much fun with EnumMap-related features and lambdas?
I have created an utilities class to handle certain EnumMap-related features, such as creating and converting between ...
6
votes
3answers
327 views
Leaving out the max value in an Enumeration
This is part of a school assignment and I came up with the following solution to leave out the max value in a Enumeration:
...
4
votes
0answers
47 views
Reading OS X file tags
I'm investigating Go for use in our internal network / office project management system, and need a way to check and edit the color tags that you can set in Finder on files or folders (extended ...
14
votes
2answers
398 views
Vector-to-direction method in Java
I don't really have a problem, but my code bothers me, because I know it could be done in a much better way.
I have an enum of 4 directions: north west, north ...
-3
votes
2answers
207 views
static factory method alternative to nested switch statements? [closed]
At first I liked the idea of nested switch statements, but on a second-look, it seems a bit confusing to read.
I'm iterating through two enum's as so:
...
5
votes
1answer
1k views
Iterable enum class in C++11
For a small project I'm working on, I've been looking for an iterable enum-like class in C++, since neither C-style nor scoped ...
8
votes
3answers
297 views
Java enum for mapping classes and specific URL
I have a ZK project in Java 6 (ZK is like ASP.NET but with zul files in stead of aspx). For showing and creating/updating the ...
5
votes
3answers
155 views
Is this good design for custom email template?
I read effective Java by Joshua Bloch. And it said use enums over int constant. So I was thinking instead of using hard coded strings I could also use enums. The forgotpassword.txt and ...
7
votes
2answers
86 views
Validating multiple keys in the builder class based on the rules
I recently started using Builder pattern in one of my projects and I am trying to add some sort of validations on my Builder class. I have already asked a question, got some feedback and incorporated ...
1
vote
1answer
67 views
Making a URL by prioritizing the keys if multiple keys are present efficiently
I recently started using the Builder pattern in one of my projects.
Below is my builder class -
...
6
votes
2answers
68 views
Efficiently returning the string basis on current datacenter
We have machine hostname as -
dbx111.dc1.host.com
dbx112.dc2.host.com
dcx113.dc3.host.com
dcx115.dev.host.com
Here dc1, ...
8
votes
4answers
597 views
An enum that has situationally invalid entries
Is it considered bad style to have that BOTH value in the Direction enum? Problems can arise from ...
3
votes
1answer
80 views
An attempt to extend an enum to prevent branching without violating the Open-Closed principle
I love making utility State enums, and giving them methods that do useful things based on which instance of the enum is provided. This works when the enum is very specific to the class I'm working on, ...
6
votes
1answer
1k views
Smart enum templates
Here is some code I wrote 10 years ago. I'm now reviewing it and there are a lot of things I don't like.
There is possibility for weird behaviour if the template is attempted to be used with a type ...
14
votes
4answers
798 views
Enum with getting subset
I just wrote this but I'm not sure if this is good practice. Can someone give me advice as to whether it's good or how I can do better or even it's bad code?
The point is that I need a sub ...
4
votes
1answer
184 views
“Agenda” test application for Enum
I'm still new in Java so I always try to find new ways and improve my skills.
I found enum in Java to be very powerful (maybe excessively?) and while I was reading ...
5
votes
1answer
72 views
Turn multiple key presses into single GameAction
The InputHandler class for my game detects key presses, turns each one into a GameAction, and raises an event.
...
15
votes
5answers
5k views
Java enum containing a hash map for look up
I have the below enum. I need to get the description by code. It is working but can it be improved still?
...
7
votes
4answers
665 views
Saving enum value using name()
Let's assume I have an enum type
enum ComponentState {
TURNED_OFF,
TURNED_ON,
SUSPENDED,
TO_REPAIR;
}
This enum describes a state of some ...
5
votes
1answer
124 views
Enumerating a boolean in C
This is one way to make a boolean in C.
typedef enum {
false = 1 == 0,
true = 0 == 0
} bool;
Recently I made some like
...
7
votes
2answers
131 views
Is there a better way to insert an enum into a set without macros?
I created an enum for a class and in the constructor I inserted all the enum values into a set. I am wondering if there is a ...
5
votes
1answer
3k views
Concerned with Enums, JSON, and ASP.NET MVC
I am writing an application that uses ASP.NET MVC for its front end, and for the back end, it uses RavenDB to store data. This ...
4
votes
1answer
218 views
Converting data when output std container via ostream_iterator
I have a strongly typed enum and std::vector of this type.
...
3
votes
1answer
153 views
Genericizing PropertyValues
This should be the last iteration for this code.
Does this approach make sense or am I heading down the wrong path?
The only thing I can see to make this better is to genericize the ...
2
votes
1answer
2k views
Automatic C++ enum to string mapping macro
I have long been looking for an elegant, one-line solution to map enum to strings automatically, for use with the << and ...
11
votes
5answers
2k views
3
votes
3answers
4k views
2
votes
1answer
605 views
User-defined color implementation in windows console
I have implemented an user defined colors enumerator, and if is possible I appreciate if I will get a code review.
I want to know if my implementation is correctly or must improve it.
If there exist a ...
5
votes
1answer
94 views
One-line initialisation for a constant list with all entries except one from another list
I'm looking to simplify the initialisation of the second constant, preferably to just one line. Any ideas? Anything from Guava or JDK (up to 1.6) is ok to use.
...
7
votes
5answers
12k views
Loading a combobox with an enum and binding to it
I have the following code to load an enumeration into a bound combo box, but am not quite happy with it.
I would prefer to store the actual enum value in the ...
6
votes
1answer
2k views
Variadic macro enum class “reflection” in C++11
I recently had the need of "reflecting" multiple enum class constructs in order to get their elements' names as std::string ...
6
votes
1answer
225 views
Critique of Cardinal Direction Enum
I'm working on a simple game in which I need to track the cardinal direction of an object. I experimented with using the enum's ordinal value, as well as using switches for the rotation, but both ...
2
votes
4answers
220 views
Enum or Constant
I'm writing a SDK for a NFC device in .NET so I don't have to import the SDK from C++. Right now I'm working on the ISO14443-3 part which is just simple Halt, Request, and Anticollision commands. The ...
6
votes
0answers
341 views
Building a good C++11 template library - compile-time checked enum array
The task is to add data or values to members of a given enum class. The compiler should check, if a value for each enum member is available, and not just default construct empty values. It is a tool ...
4
votes
2answers
1k views
Alternative to starting enum values with a number?
I have an enum like the following:
enum MeasurementBandwidth
{
Hz1 = 1,
Hz3 = 3,
Hz10 = 10,
...
}
But I do not like the ...
3
votes
2answers
113 views