Skip to main content
Code Review

Questions tagged [enum]

A data type consisting of a set of named values called elements, members or enumerators of the type.

Filter by
Sorted by
Tagged with
5 votes
1 answer
308 views

Hashable and ordered enums to describe states of a process

I am wiriting am application which needs to store information about an industrial process where products go through the following, strictly sequential phases: ...
Afelium's user avatar
  • 73
5 votes
3 answers
423 views

Implementing Generic Enumeration Classes in Domain Layer

I'm developing an ASP.NET Core application using .NET 8, following the Onion Architecture. In our domain model, we use Enumeration classes instead of traditional ...
2 votes
1 answer
115 views

Bidirectional conversion between enum and string in C

I am building an application with a lot of integer values which need to be mapped to strings for user CLI and logging. Using array LUT does not provide boundary checks so I want to generate conversion ...
jackhab's user avatar
  • 185
4 votes
1 answer
193 views

Replacement for 'enum class' with string functionality

Because I think maintainability can be done better with strings instead of plain enumerator-values when doing fstream IO, I wanted a replacement struct in my project that behaves like an ...
8 votes
3 answers
190 views

Generic overloading bitwise functions to manipulate the enum type

Thanks to G. Sliepen, who gave me a lot very meaningful & useful advice on my implementation about overloading bit operators for a special scoped enum. Now I have modified the code snippet to ...
John's user avatar
  • 469
4 votes
1 answer
410 views

Better way to add attributes to an enum in Rust for code scalability

I watched a YouTube video (https://www.youtube.com/watch?v=z-0-bbc80JM) talking about the power of enums in rust for data modelling. In the video, there's an example of a state machine of a simple ...
rafaelgdgs's user avatar
2 votes
0 answers
177 views

"Better" enumeration for C#

I've been looking to have "smarter" or "better" enum functionality in C#. There are a few GitHub/NuGet projects out there, but they seem to target newer versions of .NET and I ...
2 votes
3 answers
284 views

Java Clean Code, use of enums in data structure

I have defined a data structure in Java that allows to manage certain type of elements like a Queue, with the special feature of using 2 inner rows (windows) to attend elements: ...
2 votes
1 answer
100 views

string compatible enum-like structure

So I've decided to flex showcase my "enum that accepts strings etc..." here. I don't know if it's great but I'm pretty sure it's decent. It is implemented in less than 200 lines of code (not ...
PinkTurtle's user avatar
0 votes
3 answers
262 views

Declaring type definition once for all variables

To avoid the use of magic numbers, I created a static class to store some integer values that are represented inside a database. I avoided using enums because I need to cast them every time I use them....
Abcd's user avatar
  • 103
4 votes
1 answer
1k views

C++ enum to string conversion utility

I needed to find a way to convert a bunch of enums to string for displaying in C++. The two main ways I found when searching was using dark magic macros or voodoo magic template metaprogramming. As I ...
2 votes
4 answers
225 views

How to refactor function with string inputs to select a "mode" to avoid magic strings?

See code from this question about the advantages of Enums. ...
Jagerber48's user avatar
1 vote
3 answers
132 views

Extensible error code infrastructure

I was answering a question, Java Exception Error Enumerations Anti-pattern, on Software Engineering Stack Exchange and found myself writing up a fair bit of code. It could use a code review so I'm ...
4 votes
3 answers
2k views

Switch case on an enum to return a specific mapped object from IMapper

I have an ever growing switch case statement I plan on adding 3 more case statements to. Given an int, compare it to an enum, and call ...
Luminous's user avatar
  • 143
5 votes
3 answers
8k views

Discussing approaches for converting Enum to String

I need to convert the ENUM to a respective string value for which I came up with two approaches and I'm trying to see why would a second approach be better than the first one if even in terms of ...

15 30 50 per page
1
2 3 4 5
...
18

AltStyle によって変換されたページ (->オリジナル) /