163
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
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
26
13
2
20
24
10
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
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
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
8
u/HorochovPL Nov 10 '20
You should point out that line 2 and 3 should be merged!
4
4
u/yonatan8070 Nov 10 '20
My teacher also writes without paying attention to indentation, spelling, or spaceing around stuff.
2
1
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
1
1
1
1
u/SARCASMOOO Nov 11 '20
Not that this matters but he could of done it in three lines with a ternary.
3
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
1
1
1
1
1
u/ItsYaSoyBoyTroy Nov 27 '20
How do you indent the setup function correctly, but then slaughter the loop function?
1
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
6
u/RazvanBica8 Nov 10 '20
Not worse than my teacher's... check my post out, you'll see.