r/programminghumor • • Sep 20 '24

Meanwhile in the microsoft docs..

Post image
377 Upvotes

30 comments sorted by

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

9

u/Tsu_Dho_Namh Sep 20 '24

This same style of bug showed up in my company's code as well.

Kind of a "lack of feature" than a bug.

One of our tables was programmed to automatically sort the data before presenting it to the user. But it didn't recognize days of the week or months of the year, so it always alphabetized them.

Now it automatically checks for substrings like "Monday" or "January" and does specialized sorting if it finds them.

5

u/SwannSwanchez Sep 20 '24

yeah, it's "sorted" just not the right way

5

u/BuffJohnsonSf Sep 20 '24

That’s why the months of the year should be numbers that you sort on and then you transform that into words when you present to the user

2

u/Tsu_Dho_Namh Sep 20 '24

Unfortunately we don't have that much control over the data. Clients can enter whatever they want.

Like how Excel lets you put whatever you want in the cells, then when you tell it to sort, Excel looks for patterns to give recommendations like dates, currency, etc...

1

u/casualfinderbot Sep 20 '24

Checking for substrings sounds super brittle, should have a field that it sorts by under the hood specific to the data that defaults to the name

1

u/Tsu_Dho_Namh Sep 21 '24

Unfortunately we don't have that much control over the data. Clients can enter whatever they want.

Like how Excel lets you put whatever you want in the cells, then when you tell it to sort, Excel looks for patterns to give recommendations like dates, currency, etc...

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

u/socratic-meth Sep 20 '24

They do the needful!

3

u/Alan_Reddit_M Sep 20 '24

WHY IS IT SORTED LIKE THAT

1

u/thebatmanandrobin Sep 21 '24

Simple: it's pig latin sorted.

2

u/N0Zzel Sep 20 '24

God's work

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

u/Merzant Sep 20 '24

A weekend is Saturday and Sunday.

0

u/[deleted] Sep 21 '24

[deleted]

0

u/thebrownie22 Sep 21 '24

bro did not bother to keep reading💀💀

2

u/Cephell Sep 20 '24

wowie, a lookup table with 7 entries, an impossible challenge

1

u/littlebigplanetfan3 Sep 21 '24

Can someone explain the joke to me please? Or what it might be referring to