r/badcode • u/DrCrossBones • Jul 30 '21
python Our CS teacher just screen shared this piece of code, this is keeping in mind we have done loops, conditional statements etc a few months back
232
Upvotes
78
u/[deleted] Jul 30 '21
The more important question is why your teacher is using MS Word for code???
31
u/casperdewith Jul 30 '21
What does this code even try to do? It is such a mess!
11
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jul 30 '21
Image Transcription: Code
[Transcriber's note: The code is not in a monospace font, however in the interests of readability and maintainence of my own sanity, I have placed it in one:]
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!
11
u/scatterbrain2015 Jul 30 '21
That's why homework tasks like these need to ask for 1000 numbers, rather than just 5.
You either need to learn how to use loops, or you have to be very dedicated in order to pass.
10
u/neoeooe Jul 30 '21
Aside from EVERYTHING else, It's annoying that there are no spaces after == for the if statements, bet there is unremoved whitespace everywhere too.
I would recommend learning from other sources.
5
u/wjaspers Jul 31 '21
Not refuting the OP's observation... sometimes the CS prof's goal is to get you to identify these subtle mistakes or sloppy patterns because this you may be fortunate enough to inherit code like it.
3
u/FredTheDev Jul 31 '21
And this is why I end up re-teaching CS grads how to program.
2
u/GreyBeard4096 Aug 01 '21
Yeah, it happens. But it can go the other way too. I was stuck maintaining a bit of c gui code for a while that stored a birthdate as bdate[0], bdate[1] and bdate[2]. Just so it could use a loop to pull the data from the gui widgets. Even sticking it together after reading would have been fine but no, in the database... bdate1, bdate2, bdate3!!!
0
u/_default_username Jul 30 '21
He has covered loops and conditionals, but has he convered any basic data structures?
1
u/Deadly_chef Jul 30 '21
Everything about this is 🤮
1
u/Terrible-Butterfly-8 Aug 05 '21
Is your teacher a sports programmer?
0
u/[deleted] Jul 30 '21
[deleted] — view deleted comment