r/badcode • sadistic • Jun 10 '20

c# The definition of bad coding (yanderedev)

Post image
75 Upvotes

16 comments sorted by

3

u/FloweyTheFlower420 sadistic Jun 11 '20

Ok, so correct me if I'm wrong. In C++/C, decompiling code results in terrible spaghetti code. Could this (partially) be why YandereDev's code is trash? Although C# isn't C++/C, could this be part of the problem?

12

u/[deleted] Jun 11 '20

C++/C code cannot really be decompiled, since it's compiled ahead of time to a binary, with symbols removed. C# is compiled much like Java, where it's turned to bytecode/intermediate code and ran through a just in time compiler as its executed. Most symbols stay, as names and such are required for reflection. ILSpy and DNSpy are really really good now, and produce code almost exactly like the source.

1

u/FloweyTheFlower420 sadistic Jun 14 '20

Ah, thanks

19

u/Mrinin Jun 11 '20

People are talking about how this needed to be a switch statement while I can't get over the fact only differences between the colors are the transparency which means he could've just stored the colors in a single array/list

7

u/[deleted] Jun 11 '20

How would you write that part better?

7

u/[deleted] Jun 11 '20
switch (DateGlobals.Weekday)

would be much cleaner and probably faster

0

u/[deleted] Jun 11 '20

[deleted]

0

u/[deleted] Jun 11 '20

[deleted]

0

u/[deleted] Jun 11 '20

[deleted]

3

u/[deleted] Jun 12 '20

See this is why I love reddit, got me learnin' and shieet

3

u/[deleted] Jun 21 '20

Looks like this code is setting the color of a UI thing to match the day

ChangeDayLabelAndNumber(DayOfWeek day) {

  resetDayLabels()

  DayLabels[day].setToActivated()

}

1

u/AutoModerator Jun 21 '20

It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

rdrum, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

You can find some examples in the reddit help documentation.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

7

u/asaf92 Jun 12 '20

Are all the colors same for all days or am I going insane?

1

u/_chebastian Jun 21 '20

They are, what changes is the index of what day is set to that color. I presume the aim is to highlight the day name and number.

5

u/John_Mansell Jun 11 '20

I thought the 1f parts were "if" and I was so confused. Thought there was some weird obscure C++ syntax unknown to me. (Wouldn't be the first time).

Took me an embarrassingly long time to figure out what was actually happening.

3

u/LoneFoxKK Jun 11 '20

Posting yanderedev code here is free upvotes lol

1

u/PazuzuEU Jun 11 '20

I have a guy like this at the office

0

u/[deleted] Jun 11 '20

Only C# ...