r/badcode • • Apr 24 '21

c# Somebody applied to us today...

Post image
923 Upvotes

123 comments sorted by

281

u/DiabeticPissingSyrup Apr 24 '21

Wtf is that even supposed to do?

224

u/Snackomat Apr 24 '21

I have no idea lmao
was supposed to be a plugin checking whether a specific role has more than 5 scp-207s and if they do trigger something

83

u/INTO_NIGHT Apr 25 '21

Probably forgot if statements

38

u/Jonno_FTW shameless Apr 25 '21

When you apply for a job after reading a single tutorial.

8

u/knigitz Apr 25 '21

A single int tuto.

3

u/1_4_1_5_9_2_6_5 Apr 27 '21

I'm 99 percent sure this guy actually just learned what an if statement is. Why else have an empty else for every if?

4

u/db2 Apr 25 '21

4

u/pavilionhp_ learning from the best Apr 25 '21

So it’s just a 24-pack of coke

23

u/TheCakeWasNoLie Apr 25 '21

I don't know c#. Is an initialized variable always true?

65

u/AlFasGD Apr 25 '21

This... This wouldn't even compile.

The initialization values (at least in this sample) aren't available. Casting bool to int is not available, neither implicitly, nor explicitly. You'd need to use Convert.ToInt32/Boolean.

Therefore, the if statements would have to use bool expressions, not int expressions.

Furthermore, main returns bool, which iirc isn't a valid entry point.

4

u/[deleted] Apr 25 '21

I'm guessing that it's some weird implied return

194

u/AnotherBrug Apr 25 '21

Imagine you apply to a job and you are nervous so you log onto reddit to relax and you see your code in r/badcode 😳

104

u/[deleted] Apr 25 '21 edited Apr 25 '21

Bad manners all around. I wouldn’t want OP as teammate either.

As bad as candidates can be, there has to be some mutual respect. This goes even after you reject them.

Edit: Some advice on good etiquette while interviewing. Hopefully OP wasn't as condescending in-person. Remember that candidate could've submitted this code in a number of situations:

  • Maybe they are fresh out of college and no experience with IDE

  • Maybe they are going through a lot of job applications and stressed out

  • Maybe they wrote decent code but took easy way out for unit tests

folks are loosing their livelihood in COVID and that's not how you treat someone who is looking for a job.

4

u/Snackomat Apr 26 '21

I might need to clear up some confusion here. This is not a professional application, neither did we have a formal interview with him. He wanted to apply to a community project. The process is simply filling out a form and then having to solve an example problem. This is what they submitted.
Having said that, I thought this would be interesting to share as it takes quite some audacity to apply with a monstrosity like this. I'm still working with him and trying to help him make the best out of this, so I doubt I'm condescending there. Ultimately that is up to you to judge.

2

u/TheLifey Apr 30 '21

Hello! What is the community project? Is it working on a SCP game in a C# game engine or Unity? I'd be glad to follow and/or contribute.

48

u/Jmc_da_boss Apr 25 '21

This code is so poor it deserves no respect, i would expect better from a CS student in cs101

71

u/robert-at-pretension Apr 25 '21

The code is disgraceful, yea. We’re talking about the human who wrote the code who does deserve respect.

12

u/Jmc_da_boss Apr 25 '21

This code is so bad, that it was disrespectful to even submit it to a job application. Theres no need to defend the honor of someone who so clearly cares nothing about other peoples time.

25

u/SeesawMundane5422 Apr 25 '21

People don’t necessarily know they are bad at something until someone explains or shows them how and why to do it better. Why assume malice when incompetence is a perfectly good explanation?

14

u/droomph Apr 25 '21

I don’t submit applications to be a civil engineer and just go “oops” when I don’t know what the difference between rebar concrete and regular concrete is, or whatever the 101 is for that. Or like, I don’t apply to be an accountant just because I can use TurboTax.

There’s a certain level of “I know I don’t know” that everyone should have.

1

u/MasculineCompassion Apr 25 '21

Bruh, look at that code. They clearly had no idea what they were doing, or they were trolling.

2

u/SeesawMundane5422 Apr 25 '21

You: “Clearly had no idea what they were doing” Me: incompetent

Aren’t those the same thing?

7

u/Kyn21kx Apr 25 '21

While I can totally see what you mean here, as u/SeesawMundane5422 pointed out, not everyone knows they're bad, or perhaps they just really need a job, we can't really judge bc we don't know the full scope of this person's situation...

HAVING SAID THAT

I don't think it is entirely disrespectful from OP to share this, I think we can all look back at the code we've written long (or in some cases not so long) ago, and just wonder what the hell were we thinking, highlighting this as bad code could potentially lead other people to learn why this is bad, and how they can improve if they ever see themselves in similar situations

1

u/1_4_1_5_9_2_6_5 Apr 27 '21

Yeah but this is the kind of code that shows that 1) the person writing literally doesn't know how to use an if statement and 2) they don't even bother to test their code before publishing it. What kind of programmer is that? Someone who read the first page of a book on programming and figured it was good enough to get a job.

1

u/ZeCactus Apr 25 '21

Maybe they are fresh out of college and no experience with IDE

I wouldn't expect code like this even straight out of high school.

1

u/Florian0205 Apr 26 '21

Thank you for thinking of others.
But I think you need to know some background.
The person who wrote this code applied to join the devteam of our gaming community.
Like me, he still goes to school. Just to let you know he's not looking for a job.
He's new to C# and we sometimes give him some advice.
The code you saw is the first code he send to us.

1

u/1_4_1_5_9_2_6_5 Apr 27 '21

What is he going to school for? I highly doubt its anything programming related, unless he's failing.

37

u/IGambleNull Apr 24 '21

kekw I hope we don't accept this crackhead

53

u/Snackomat Apr 24 '21

He is 5 parallel universes ahead of us...

11

u/TimGreller Apr 25 '21

I think he's >= 5 cokes ahead of you.

10

u/Max5923 Apr 25 '21

4d coding

36

u/winter-ocean Apr 24 '21

I take it this is from an SCP fan game but yeah this is really bad.

19

u/IGambleNull Apr 25 '21

It should be a server plugin for SCP:SL

26

u/Snackomat Apr 25 '21

Atleast supposed to. Thing is: I highly doubt it's working in this state :,)

19

u/N3crom0rph Apr 25 '21

This is an SCP by itself

629

u/matt1484 if true else false Apr 24 '21

That person takes the sharp out of C#

156

u/Ahajha1177 Apr 25 '21

Cb

72

u/drdrero Apr 25 '21

C minor

54

u/[deleted] Apr 25 '21

/r/badmusictheory

minor got nothing to with sharpness/flatness

69

u/circorum Apr 25 '21

Found the C major

12

u/LordDoomAndGloom Apr 25 '21

Take my poor man’s gold: 🏅

5

u/drdrero Apr 25 '21

but it has something to do with a joke

7

u/[deleted] Apr 25 '21

Ok, this is Reddit and we're all fucking around but I'll try to explain why it doesn't work as a joke - because this is a weekend and wth. C# means that it's a note higher than C, it's not a type of C. The same note could have been called D but western music blabla. The point is the pitch is higher than C so it works as a 'C# is better than C' joke. (up means 'better' most of the time). So the joke that removing the # from C works, the follow up Cb is also a good joke follow up.

Now C minor is actually 'a type' of C, we can talk about the minor key or the minor scale itself but the point is its rooted in C. It's not "lower" in any sense. Sure I guess if you just think of the word minor it would seem like a weak version of major but unlike pitch there's really no objective measure. It's just a different flavor of C, kinda like juice, you can have grapes or orange flavor but you can't really compare them in an objective scale. Thus saying C minor doesn't really work because C minor is not 'bad' compared to anything. At least with sharpness/flatness we could joke that the higher the pitch the better.

10

u/drdrero Apr 25 '21

A C minor is an underage C programmer, which most likely was the one writing the bad code

3

u/[deleted] Apr 25 '21

Ah that's good, lol. this is the perfect response to my try-hard reply.

2

u/drdrero Apr 25 '21

I appreciate your effort though. Good write down

1

u/[deleted] Apr 27 '21

More accurately, C# Minor!

2

u/[deleted] Apr 25 '21

Disagree. In a C minor chord, as opposed to a C major chord, the 3rd is lowered (not sure if I say that correctly), and as you said, lower == worse etc. So it still works for me

2

u/[deleted] Apr 25 '21

You have a point. I was thinking more of the scale as a whole, because they all end up in the same place with the same number of notes - just the interval between the notes are different. But yea if we're talking basic chords (triads) then you're right about the minor 3rd, good catch.

1

u/[deleted] Apr 25 '21

Fair :) I would agree the other joke does work better, this one is indeed a bit farther fetched.

1

u/jaysuchak33 ifelseifelseifelseifelseifelseifelseifelseifelseifelseifelse Apr 27 '21

If you want to get all theoretical about it, let's talk about modes.

There's different types of scales that can be built upon a root, the most commonly used ones are major and minor (ionian and aeolian)

You can go through different modes by chromatically altering one or more notes in the scale, you can also take this to the next level by staying in the same mode but modifying it like melodic and harmonic minor but let's just stick to the pure modes.

If you take a major scale which is the most commonly used one, you can convert it to minor by flattening the 3rd, 6th and 7th note in the scale. Alternatively you could keep the notes the same and change the root so that it's the 6th of the original major scale(this is the relative minor) but in this case we want to keep the root the same. Thus a minor scale is technically "flatter" than a major scale because it has flattened notes(or natural notes instead of sharp ones if we're counting C# as the root).

Definitely not saying that minor scales are worse than major though. In my opinion they're a lot more interesting and spicy compared to vanilla major

1

u/[deleted] Apr 25 '21

So B

2

u/ColdPorridge Apr 25 '21

But sometimes C-flat

1

u/RyanNerd shameless Apr 25 '21

To make sense of this code I've concluded that the variable coke is alias for cocaine.

162

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Apr 24 '21

Image Transcription: Code


using System;

namespace Test
{
    class Program
    {
        static bool Main()
        {
            int coke = SCP207;
            int Dboi = ClassD;
            int Scient = Scientist;
            int Guard = FacilityGuard;
            int Tuto = Tutorial;
            int Chaos = ChaosInsurgency;
            int NtfL = NtfLieutenant;
            int NtfK = NtfCadet;
            int NtfS = NtfScientist;
            int NtfC = NtfCommander;
            int Spec = Spectator;
            
            if (Dboi)
            {
            coke >= 5;
            }
            else
            {
            
            }
            if (Scient)
            {
            coke >= 5;
            }
            else
            {
            
            }
            if (Guard)
            {
                coke >= 5;
            }
            else
            {
            
            }
            if (Chaos)
            {
                coke >= 5;
            }
            else
            {
            
            }
            if (NtfL)
            {
                coke >= 5;
            }
            else
            {
            
            }
            if (NtfK)
            {

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

48

u/Blendify Apr 25 '21

Good human

128

u/mosskin-woast Apr 25 '21

You poor soul, bless you

17

u/MrNakaan Apr 25 '21

Good human.

3

u/CaJoKa04 Apr 25 '21

This just reminds me of why i prefer indentated languages over those which use brackets

32

u/[deleted] Apr 25 '21

You don't need a single curly bracket in that big chain of ifs

6

u/ososalsosal Apr 25 '21

I feel weird making my c# look like python tho. I only do it if the linter does it

2

u/AestheticalGL Apr 25 '21

Are you from Northwood?

6

u/Snackomat Apr 25 '21

I am affiliated with them, however not an official staff member. We're running one of the largest german community servers.

126

u/mosskin-woast Apr 25 '21

Does the expression coke >= 5 evaluated on its own even do anything??

74

u/dirtball_ Apr 25 '21

false

24

u/Omichron-the-reboot Apr 25 '21

Or true, in some cases

7

u/th3f00l Apr 25 '21

With some exceptions

15

u/[deleted] Apr 25 '21

In C++ it might, if coke is a macro with side effects, right? Like #define coke (rand() == 0 ? exit(1) : 1)

2

u/[deleted] Apr 25 '21

That's a question for the compiler, do they even just scratch out 'useless' statrments like this or still process it.

4

u/spaghettu Apr 25 '21

Not sure about C#, but for most C++ compilers depending on the optimization level things like this should be completely optimized away

1

u/oddark Apr 25 '21

In C#, that would give a compile error

1

u/RFC793 Apr 25 '21 edited Apr 25 '21

Edit: I missed the type definitions, but if these were not primitive types (such as int), or if we don’t know the type from the context of the snippet:

It could in a language that allows operator overloading such as C# (this code) and C++. But comparison operators should never have side effects. Doesn’t mean crappy code must abide by that rule though.

Imagine overloading the >= operator to say “if I’m being compared against 5, format the hard drive”.

1

u/nati9931 Apr 25 '21

Because it does nothing the Compiler will optimize it out... the Compiler will probably just not compile any of it.

37

u/truemario Apr 25 '21
else
{

}

Those empty else cases. 🤦‍♂️

16

u/MyAntichrist Apr 25 '21

I had a colleague who would put a comment "no op" in those. All the time.

1

u/[deleted] Apr 25 '21

Maybe they tried to do an elseif

33

u/PopularExpulsion Apr 25 '21

This might be the worst code I've ever seen.

27

u/MopicBrett Apr 25 '21

Ay but you have heard of him

0

u/[deleted] Apr 25 '21

[deleted]

2

u/PopularExpulsion Apr 25 '21

I have (and we all have) written some pretty shitty code when I started, but nothing like this. This is pure illogical nonsense.

32

u/NetherFX Apr 25 '21

My man invented a whole new language, C Dull

3

u/Naeio_Galaxy Apr 25 '21

One day, the C Dull will evolve into D Very Dull

15

u/vitalKnowledge Apr 25 '21

So, did they get the job?

2

u/[deleted] Apr 25 '21

idk but he will find one .... ;-;

7

u/[deleted] Apr 25 '21

Did they not try and run it before submitting it?

7

u/Miuzu Apr 25 '21

Plot twist: reading this shitty code is a cognito hazard.

1

u/wheres_that_tack_ow Apr 25 '21

I recognize the syntax in the file

13

u/[deleted] Apr 25 '21

Alr this person gave me enough confidence to apply to you. You still taking?

18

u/iovilius_ Apr 25 '21

did yandere dev write this?

2

u/Spynder shameless stealing content to r/YandereTechnique Apr 25 '21

I would have linked r/YandereTechnique, but no, this is just wrong on all levels.

5

u/coolj492 Apr 25 '21

Wait did someone actually sit down in an interview and type this?

4

u/green_kerbal Apr 25 '21

So if something is true it is supposed to check if coke>=5? And then?

8

u/taptrappapalapa Apr 25 '21

What I think the thought process is that since Main is a bool return type then the if statements will return a bool from “coke>=5,” but I’m pretty sure C# requires the “return” keyword to do that

3

u/[deleted] Apr 25 '21 edited Apr 25 '21

Correct. Also c# doesn't let you use anything except a boolean as a boolean.

You can't even use nullable booleans as booleans (except by casting).

So those if statements shouldn't even compile.

3

u/HereComesCunty Apr 25 '21

I’m quite sure that ain’t ever compiling. You can’t just if(int), there’s nothing for the if to resolve true or false.

Looks like it was written by a JavaScript dev on crack

3

u/TimGreller Apr 25 '21

Wh- Wha- Why??

5

u/marxio1 Apr 25 '21

had a stroke trying to understand what they're trying to do

2

u/dado243 evil Apr 25 '21

Secret lab dev?

2

u/Whiskee0001 Apr 25 '21

The person who wrote this should be considered an scp lol

2

u/iambertan Apr 25 '21

because fuck switch case

1

u/Taksin77 Apr 25 '21

Do they have case in c#?

4

u/HereComesCunty Apr 25 '21

switch? it has switch

1

u/C3_Kiwi Apr 25 '21

What am i looking at

1

u/[deleted] Apr 25 '21

👀<-----<<

1

u/XDgierman Apr 25 '21

Am I stroking? Is this how having a stroke feels like?

1

u/BongarooBizkistico Apr 25 '21

This is evaluating booleans and then doing absolutely nothing with said evaluations? I'm guessing the compiler removes those so the code is literally doing nothing?

1

u/AGI_69 Apr 25 '21

I dont know why, but this post makes me really really sad

1

u/Ich_bin_da Apr 25 '21

I dount know c# well, but why the fuck are those integers assigned to a String?!

1

u/nati9931 Apr 25 '21

It does literally nothing. The compiler will ignore all of it

-1

u/AffectionateSimple94 Apr 25 '21

Fail for bad indentation. Also the code doesn't look good.

-4

u/Shakespeare-Bot Apr 25 '21

Fail f'r lacking valor indentation. eke the code doesn't behold valorous


I am a bot and I swapp'd some of thy words with Shakespeare words.

Commands: !ShakespeareInsult, !fordo, !optout

3

u/[deleted] Apr 25 '21

I'm tired and dying laughing

0

u/[deleted] Apr 25 '21

[deleted]

13

u/SharkLaunch Apr 25 '21

Also, the code in the if blocks aren't even doing anything. The results of the expressions aren't used.