34
u/GoogleIsYourFrenemy Sep 20 '24
If you are looking at the underlying "value" of enumerations, you are using them wrong.
22
u/picklesTommyPickles Sep 20 '24
That depends. If they ever get serialized and stored in a DB as their int values then sometimes you need to look up what the underlying values are
12
u/Jjabrahams567 Sep 20 '24
It’s also nice to have a modulo incrementer for something like this. So Tuesday + 1 = Wednesday
-2
u/GoogleIsYourFrenemy Sep 20 '24
You serialized it in a form that doesn't match how it's going to be used (read by humans), that sounds like a good idea.
Seriously, you chose not to make it readable, you could have created a function or a table to make it readable if you insist on storing it as an int.
5
u/who_you_are Sep 20 '24
How to tell us you aren't a programmer without telling us you are a programmer.
Everything ends up being more efficient as number behind the scene. So there will be, at lest one peoples that will have the job to convert it to number somewhere.
It may be useless for you, but there will be plenty of other cases where you would use that value billions of time in a short window. That user-friendly thing now add minutes to your process, eat more bandwidth (or whatever) which will create other issue down the line.
You created an enum in your database? I won't even be surprised if your database converted it into a number behind the scene...
Sometime, not having numbers makes it even harder even if you are creating such value from and for your own software.
And the funny thing, you may also end up with a similar unfriendly behavior with name. "Why is TACO meaning Friday? - it was the day we had taco but for legacy/compatibility reasons we couldn't rename it".
4
u/picklesTommyPickles Sep 20 '24
Have you never heard of an ORM? Most, by default, will store just the int value of an enum for obvious performance reasons. Most of the work will be done through the ORM and transparent to the dev but sometimes you need to troubleshoot at the data layer
15
u/SonOfMetrum Sep 20 '24
If only. Microsoft outsources much of it’s documentation activities to India… It’s not that I’m implying that they are not doing a good job. More that Microsoft doesn’t care to do it themselves.
8
3
2
2
u/BlackTorr Sep 20 '24
For me its funny that sunday is day zero but also the last of the week.
-2
u/thebrownie22 Sep 20 '24
How is it the last day of the week?? The last is Saturday, then starts back at Sunday.. Thats why they're called "week-ENDS". There's always 2 end points on a line. Monday is not a weekend
1
u/jryser Sep 20 '24
I think weekends is just the plural of weekend.
Week-end, of course, implying that it happens at the end of the week
0
u/thebrownie22 Sep 20 '24 edited Sep 20 '24
Turns out it's based on religion whether Sunday, or whatever other day is first in the week.
But I meant, you'd call Saturday a weekend, and youd call Sunday a weekend, therefore together its 2 weekends, but in the context of a single week, you'd say "the weekend".
I could, and possibly am wrong about that, but it just turns into an English debate at that point
2
u/jryser Sep 21 '24
This may be a regional thing, but I’ve generally only ever heard Saturday/Sunday referred to as “part of the weekend”, not entire weekends by themselves
1
u/thebrownie22 Sep 21 '24
Yeah, I have no idea, both sound right, but it just goes back to being an English debate, which I'm not one to talk about lmao
1
0
2
1
u/littlebigplanetfan3 Sep 21 '24
Can someone explain the joke to me please? Or what it might be referring to
73
u/SwannSwanchez Sep 20 '24
i mean...
it's "fine"
it's sorted abc, at least it's not
1 for friday
2 for monday
3 saturday ect ect