r/badcode • • Nov 10 '20

c++ My teacher's code formatting

Post image
983 Upvotes

60 comments sorted by

6

u/RazvanBica8 Nov 10 '20

Not worse than my teacher's... check my post out, you'll see.

3

u/[deleted] Nov 10 '20

Oh god wtf is that

3

u/The_Northern_Light Nov 10 '20

Jesus christ demand your money back.

163

u/The_Grandmother Nov 10 '20

Kill it with fire

14

u/Aquillium Nov 10 '20

Then piss on the ashes

126

u/CW_Waster Nov 10 '20

This should be illegal

15

u/midwestraxx Nov 10 '20

I mean the formatting is probably from copy-paste from a doc or website, which is usually against plagarism rules sooo /s

6

u/Mr2-1782Man Nov 11 '20

Nah, I've seen plenty of profs write crap like this. The same ones that will be anal about math symbols and units tend to be the ones that write code that follows no style.

2

u/[deleted] Nov 11 '20

that’s what it looks like to me too. I think they typed the first function themselves though.

58

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Nov 10 '20 edited Nov 10 '20

Image Transcription: Code


void setup()
{
  pinMode(12, OUTPUT);
  Serial.begin(9600);
}

void loop()
{int light=analogRead(A0);
 Serial.println(light);
  if(light>250)
  {digitalWrite(12,HIGH);
  }
 else
 {digitalWrite(12,LOW);
}
}

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!

79

u/Unkn0wnSoul Nov 10 '20

The damage has already been done, no need to make it worse

26

u/adamski234 Nov 10 '20

Line 8, unrecognized identifier: anologRead. Did you mean analogRead?

19

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Nov 10 '20

Fixed, thanks!

13

u/500_internal_error Nov 10 '20

Good human

10

u/[deleted] Nov 10 '20

Your username is the stuff of nightmares

2

u/[deleted] Nov 11 '20

That’s cool that transcribers exist. Probably really good for accessibility!

20

u/MustachedSquid Nov 10 '20

I need bleach

5

u/[deleted] Nov 10 '20

[removed] — view removed comment

24

u/MicroMezzoMacro Nov 10 '20

He's a sociopath

10

u/The_Northern_Light Nov 10 '20

I'm calling the Hague.

4

u/therealpussyslayer shameless Nov 10 '20

i just physically gagged

9

u/BlackTorr Nov 10 '20

Idk why some people save spaces like they are paying for them.

3

u/menjav Nov 11 '20

Because it’s highly optimized code. Everybody knows those extra spaces make the execution slower. /s

2

u/BlackTorr Nov 11 '20

Ah yes, a compiler whisperer.

34

u/hhellloo Nov 10 '20

The code itself doesn't look bad. Just the formatting.

68

u/ZedTT Nov 10 '20

Hence the title

19

u/hhellloo Nov 10 '20

Yeah, but the subreddit is bad code. And bad code practises is what I (and most likely others) expect on this subreddit.

73

u/ZedTT Nov 10 '20

Ehhhhh I think bad formatting kinda constitutes bad coding practices. Really hurts the readability. I think it fits the spirit of the sub pretty well.

20

u/hhellloo Nov 10 '20

You are right.

0

u/NahroT Nov 10 '20

Hence the upvotes

9

u/LeeHide Nov 10 '20

bad formatting is bad code. you might say

"you can just reformat it"

and yes, you can, but you cant do that if this is code in a repo that you have to commit your changes back to.

1

u/sporadicPenguin Nov 11 '20

Wait, why would you not be able to reformat then commit?

1

u/LeeHide Nov 11 '20

because it would likely change like half the file and if you commit that it becomes difficult to merge with other changes later

9

u/deftware Nov 10 '20

Now I know what they mean when they say

Those who can't do, teach.

8

u/HorochovPL Nov 10 '20

You should point out that line 2 and 3 should be merged!

4

u/[deleted] Nov 10 '20

...

{pinMode(12, OUTPUT);

...

???

7

u/mudkip908 Nov 10 '20

Yes, to make it consistent with the rest of the shitty formatting.

4

u/yonatan8070 Nov 10 '20

My teacher also writes without paying attention to indentation, spelling, or spaceing around stuff.

2

u/noXi0uz Nov 10 '20

I puked a little

1

u/thanatica Nov 10 '20

He/she is clearly a masochist.

1

u/zBrunoLEOz Nov 10 '20

Unfortunately, that's also how some of my friends do their code. And their teachers. And my teachers.

1

u/computercluster Nov 10 '20

AT LEAST BE CONSISTENT!!! FUCK!

1

u/lol-game Nov 10 '20

Arduino Uno 😑

1

u/Shadow_Being Nov 11 '20

to be sort of fair. the Arduino editor sucks.

1

u/SARCASMOOO Nov 11 '20

Not that this matters but he could of done it in three lines with a ternary.

3

u/[deleted] Nov 11 '20

could of

You probably meant "could've"! It's a contraction of "could have".


bleep ^bloop I'm a ^bot. If you have any questions or I made an error, send me a ^message.

1

u/_default_username Nov 11 '20

Man, your teacher needs to use a code formatter. I have my IDE auto format my file when I save so I don't have to worry about the formatting portion of code styling.

1

u/hddnblde Nov 11 '20

yo that
}
}

is killing me :(

1

u/the_real_Spudnut2000 Nov 11 '20

This makes we want to die

1

u/[deleted] Nov 17 '20

It seems like most ppl who are into arduino doesn't care that much about programming

1

u/[deleted] Nov 18 '20

the more you look at it, the more it triggers you.

1

u/ItsYaSoyBoyTroy Nov 27 '20

How do you indent the setup function correctly, but then slaughter the loop function?

1

u/ronsachdeva Nov 10 '20

It burned my eyes

1

u/korben_manzarek Nov 10 '20

Eh, an arduino program with about a dozen lines, don't think formatting really matters there, it's still very readable. Also, the IDE for arduino isn't very conducive to good formatting.

0

u/[deleted] Nov 10 '20

[deleted]

2

u/[deleted] Nov 10 '20

Yes.

0

u/[deleted] Nov 10 '20

[deleted]

1

u/Adybo123 Nov 10 '20

“Arduino Language” is just an SDK atop C/C++