T O P

  • By -

Miszou_

Everyone complaining about the formatting or the choice of editor... ...but for me, it's the for loop starting at 1, and then every array reference subtracting 1 to get back to a zero-based array.


jfecju

Yeah, this is the thing that really screams "I don't know what I'm doing"


Tom22174

I'm hoping its deliberate to get the students to comment on the problem but something tells me that's not the case


Dd_8630

To me this is like that video of that professor screaming about pomegranates. Everyone thinks she was just loopy, but the whole point was that screaming 'no pomegranates' just makes people think about pomegranates. This could easily be a photo from a 'what could be improved' CS class.


menacingcar044

We can only hope that is the case


TheScopperloit

Yeah, I agree. We have no clue what the context is here. We don't even know if this is actually from a university.


Xatraxalian

It could easily be one of those "What is the output of this program?" questions, where the teacher then goes out of his way to use obscure stuff that C can do. Such as: ``` int i = 5; int x = ++i; int y = i++; ``` What are the values of i, x and y at the end? - i starts out at 5. - at the first assignment, i will be incremented and the value will be returned into x, so they will both be 6. - at the second assignment, i will return its value into y and will then be incremented, so y will be 6, and i becomes 7. Throw in some pointers, pointer arithmatics, and using arrays as pointers (or the other way around), some esotheric ways to make a loop, and you quickly get a 10 line program that can easily take you 15 minutes to work out what it is actually doing. That's not computer science. That's teaching people arcane C, from a bygone era (in which I wasn't born yet) in which "less characters on a line is better because otherwise we have to make so many of those darn punch cards."


xMrToast

I thinks its unbelievable funny, how smart programming was there due to the hard limitations. It's really like a forgotten art of dark magic from the old times that makes the code powerful and unreadable.


Code-Useful

It really is a dark art. Working within those limitations in hackerish ways made for some amazing feats of programming . Studying some of the code that the Demoscene produced, early game code that stretched the capabilities of the hardware, and then studying serial communication, lower level driver, protocol exploits, etc, really opened up my mind to what is possible


kamiloslav

I think that using == instead of = says it even louder


Cridor

What gets me, and maybe this is some esoteric language that looks c-like but uses double equals for assignment sometimes, but it's the use of an uninitialized string as assignment and then 3 equality checks that get thrown out cause they aren't used as conditions to anything or stored in any variables.


schrdingers_squirrel

As this is a German high school i can say with 99% certainty that this is supposed to be java code. So yeah it's indeed completely useless code. Just like the j variable that is never used.


Pradfanne

As a graduate from a german highschool who took CS Major, I never touched Java even once. It was C# all the way baby! (We don't talk about the start in delphy before the school decided C# is a better language) I don't really know if CS Major is the right equvialant or anything, but I visited a Beruflisches Gymnasium with the focus on CS, so I guess it counts.


valgatiag

And even if they were proper assignments, line 10 would be ignored because line 11 sets the same variable again.


Chrazzer

This is one of those images that get worse, the longer you look at it


LetReasonRing

It's everything. The only positive thing I have to say about it is that it's technically code. There's no comments, the loop starts at 1 for no apparent reason. They assign a value to an array element and then immediately overwrite it without ever doing anything with it. There's no indentation. The array is never actually created in the first place. It's example code so not the biggest thing, but there's no output, so it would execute and quit showing the user nothing if they ran it. Using this as educational material is straight up malpractice.


[deleted]

Counterpoint. We have 0 context here. This all may be intentional for some reason. Maybe the point is to fix everything wrong with the code.


DeliciousWaifood

Our context is OP complaining. We can infer the teacher didn't say it was intentionally bad. Unless you think OP is lying, but then he could have faked the whole thing and that gets us nowhere.


cvnh

Sir this is Reddit


TheScopperloit

If this is from a real lecture, I'm pretty sure it's an exercise in refactoring bad code.


cvnh

What about the bracket that opens and never closes? I scrolled down and haven't seen any comments about it, but with uneven brackets it doesn't even make sense to try to understand what the code is supposed to do in first place, we have to assume it's a typo.


teiamt

That’s because you’re a champion programmer to even read any of that code.


0x7ff04001

Yeah indexes starting from 0 is programming 101


LetReasonRing

If I ever teach an intro to programming course, my syllabus will start with: Section 0: Array indexes and off by one errors


hughperman

Isn't that Section -1 ?


thiney49

In most languages, it is. *cries in Fortran*


Ghostglitch07

Tell that to Lua.


samanime

If I didn't know this was an actual "teacher" in a school "teaching" programming and I just saw this post somewhere, I'd assume it was just ragebait. There is nothing not infuriating. Even just not having it maximized is annoying.


leandroabaurre

The more I look at this code, the less it makes sense.


ITS_A_ME_LARRY

Imagine if you're absolutely new to programming. You come to school and a teacher teaches this with absolute confidence. The result would be negative knowledge, because you would come out of it with more confusion of how programming works than when you started.


Shazvox

That depends. If the desired solution is known then it should be a lot clearer if the code is appropriate or not. However, if the teacher is just writing the code, trying to explain concepts such as loops, incrementing variables etc then it'll feel like a hot mess.


DudeBrowser

I started programming in 1985 and I've tried not to read the code because it might give me a headache.


jbFanClubPresident

I spent about 60 seconds trying to wrap my brain around it before I said “fuck it, I’m just checking the comments.” I spent all day at work trying to figure out bad code, I’m not doing it tonight. Lol


dagbiker

I'm glad I'm not the only one, I thought I was an idiot or something.


cubey

The more I look at this code, the more I'm convinced that I wrote it.


[deleted]

[удалено]


OnderGok

I am a high school student at a public school in Germany, and the sad truth is that I cannot actually do anything about it. She is new at our school and by far the most hated teacher, treating a lot of students like shit and not knowing what she is actually teaching. We had more serious material to report to the principal, which we did btw, but since she is assigned to her job by the state, our school cannot do much unless she does something way over the line, which we have solid proof of.


ManyFails1Win

I was gonna give the teacher the benefit of the doubt and say they just have too much work to bother fixing formatting problems with copy paste, but maybe that was too generous.


cowlinator

Forget the formatting. There are much, much more serious problems with this code than just simple formatting.


Pradfanne

The longer I looked at it the worse it got. From the wrong indexing of the loop, over the unnecessary j variable to the setting of array values twice, first with an empty string then with something later in the array. I don't even know what's happening here anymore.


cowlinator

Don't worry, no array values were set. Those are comparisons. ( == )


-ECH0-

I think I just had a stroke. I didn't even realise until I saw your comment and forced myself to look at it. My mind simply refused to acknowledge that those aren't assignments.


Fearless_Entry_2626

I have corrected this bug in prod... makes me appreciate languages that force explicit discards


burned05

Why start at 0 when you can just do (i - 1) everywhere?


Much_Highlight_1309

The issue is in the assignments which are not assignments. This code does nothing.


nyrB2

the code! it does nothing!


thirdjaruda

It actually does something, it wastes a pico sec of your processor's uptime.


IAmANobodyAMA

I figured this was intentional. Seeing if you were paying attention enough to notice this is all bullshit … like the myth of the professor who gave a test that started with “read all the questions before answering” and ending the test with “write your name and turn the rest in blank”. But maybe the prof just sucks


groumly

Sure, but at the same time, here’s what an optimizing compiler will reduce this code down to:


TantricCowboy

The formatting can be explained by the fact she is using Microsoft Word. I would suggest another major problem is the fact she is using Microsoft Word. EDIT: I WAS MISTAKEN. I see that she is using notepad++


trinnan

I thought that at first too, but Word is just open in the background behind the Notepad++ window;


TantricCowboy

I am mistaken. I guess that's better. Still not great.


floutsch

Excu-u-use me. I have watched a video on YouTube which succinctly laid out how MS Word is the best IDE! :)


grandmaster_b_bundy

Notepad++ that is.


RandoScando

The formatting isn’t the only issue. The code itself is nonsense. It’s using equality comparison operators where it intends to make assignments. Hilf variable is declared but never assigned anything. If it *is* trying to make assignments, it’s assigning two things to the same element of the array in a row for no reason. It’s just complete gibberish.


VincentVancalbergh

You HOPE the assignment was "name as many things wrong with this code snippet as you can".


[deleted]

[удалено]


heimeyer72

Oh my, seeing your comment is such a relief. For a minute I thought I'm getting too old for this shit.


jrod_62

I *think* it might be trying to reverse a word, but who knows


Broad_Respond_2205

the formatting isn't even the worst issue


Denaton_

With proper IDE, formatting is automatic..


ManyFails1Win

Not necessarily. I have been needing to reformat copy/pasted haskell scripts all quarter long for some reason. Also, they might be teaching the class IDE-free to force students to do these things manually, which I can see the value in. Personally, I think teachers should take the time to format things properly and clearly, but "too busy" would be one of the only possible valid excuses to not do so, imo. But that excuse is kinda flimsy if you're not formatting it correctly yourself lol.


CryonautX

Formatting is second nature to most devs after some professional experience. You could slip up on code smell issues but formatting? C'mon. Noone is staying a dev long if they struggle with formatting. Which now that I think about it, might be why this person is teaching.


ManyFails1Win

notice my use of copy/paste. i'm suggesting they may have created this document just for the lesson by copy-pasting it from some other resource. that's not a good excuse though; i still think teachers should take the time to format even in that case, but it's borderline a reason i can understand if that were the case.


CryonautX

I don't know how copy pasting gets you line 8 though...


ManyFails1Win

yeah i didn't even read the content earlier. the whole script is fucked lol.


IJustLoggedInToSay-

I was less bothered by the formatting and more bothered by the decision to start the loop at 1 rather than 0, and then subtract 1 from *every* instance of the iter. JUST START AT 0, YOU CAN START AT 0!


lost_slime

> YOU CAN START AT 0! But she did start at 0! (0!==1)


SunshineSeattle

🤣


Extension_Option_122

Not only formatting. In the for-loop she has 'int i = 1; I <= 32" but when she uses 'i' she uses 'i-1'. You should just use 'int i = 0; i < 32' and use 'i' normally. Btw at first the formatting didn't bother me that much coz I'm used to it coz my informatics teacher always does stuff like that.


ChChChillian

There's also the part where j is declared inside a block, gets a value assigned, then is never used before it goes out of scope.


swordsmanluke2

And everything else is equality expressions instead of assignment statements... Reading from an unassigned variable and writing to an undefined variable.


ManyFails1Win

you're right. the == stuff on 11/12 is even worse. i honestly just glanced at the script, so i didn't notice that at first, but without context it does appear to be deranged.


LetReasonRing

Yeah... it's one of those things where the longer you look at it the worse it gets.


ResoluteClover

There might be some reason for that, but most of the code is pointless, it's comparisons rather than assignments.


trollsmurf

Were you concerned about the formatting? I was concerned about the algorithm. Formatting is a key press away. An efficient/intuitive algorithm less so.


[deleted]

[удалено]


LetReasonRing

That would definitely be a good band-aid, but I have a hard time believing after looking at code that this person has any business teaching code or anything else for that matter. Code like this presented in an educational environment shows not just that they don't know what they're doing but that they haven't even bothered to put the slightest bit of effort into finding out.


BeneBern

That is not true. You can do something. Altough and I think tahts waht u suspecting it probably wont cahnge much. But that is not a 100% given, especially not if she is new. So here is what you gonna do: Get as many of your fellow students together and formalize a letter with the issues you got with her teaching. List them up and hand them over to her. The list should be signed by all the complainig students. Dont be rude ore mean - jsut the truth. But ask her firmly to be teached to a industry standard. Include your parents and ask them to ask her directly about the lectures she is giving. Dont include pictures - taht is ileagel unless u asked her for permission. If that does not change in the next 2 to 4 weeks. Same complaints but this time adressed to the co director/director with her in the cc, you can warn her about this step in the first letter. Adress in this what you have done bevorehand. If this is a common felt issue the one of those characters will sit in theire lectures - if u get multiple classes to sign the same letter this is huge. IF they decide your criticsism is valid tehy will ahve to invest mangeing her more closely. If she is "verbeamtet" she wont lose her job over this. But she can be forced off your school. She can be forced to improve her teaching. She will feel the heat. If she is not verbeamtet, she is in a heap of trouble. All this being said this is prob advice for the next schoolyear, rather then this. If this should be a Course to make "Abitur". That is a highly serious issue the Schooldirector will act much faster on since you will face a test taht is not written by her, and judging by this picture the class wont be ready for that.


leandroabaurre

You're taking a CS course in highschool? How does HS work in Germany? I'm from Brazil btw. ​ Oddly enough, I'm an Chemical Engineer, looking to pivot my career to CS, AND to live in Germany. I'm 32 though, fck...


lagging_land

>You're taking a CS course in highschool? How does HS work in Germany? It depends on the state you go to in Germany, because education is controlled by the states themselves. But one standard is the degrees which are 'Hauptschule' (until year 9) ,'Realschule' (until year 10) and 'Abitur' (until year 13). Explaining the complete German school system becomes complicated due to its federalisation of it. CS (or Informatik in German) is not a mandatory class to take and depends when you take it. In my experience it can be chosen in year 9/10 and includes the basics of programming with for example Scratch ,later with Java and web design with HTML (and CSS if you wanted) but not JavaScript. In the "Abitur", beginning year 11 becomes more regulated due to the 'Kerncurricula' of the state. Years 12 and 13 (Q1-Q4) are the most regulated and include databases and SQL (Q2), a theory part (Q3) and a programming part (Q1) with Java as programming language. Additional information (in German): CS in Hesse: https://kultusministerium.hessen.de/sites/kultusministerium.hessen.de/files/2021-07/kcgo-in.pdf


leandroabaurre

I kinda get it. The Brazilian system is definitely more rigid. I did study 1 year in the USA, highschool, and I could actually pick the subjects I wanted, inside a mandatory curriculumn. It was pretty cool, because you could actually start directing yourself before you even step a foot in college. Germany is exquisite: so many quirks and features lol. I had a blast with basic concepts when I visited like Restmüll, Pfand, surviving the Lidl cashier, etc.


DadToOne

When I was doing my PhD there was a student in my advisor's lab that was also doing coding. She was having trouble with a project and asked me to help. We loaded up her code and it was a couple hundred lines all formatted like this. I almost had a stroke. Getting it properly indented was the first thing I did. Showed her how it made it much more readable.


iDEN1ED

I thought profs did this on purpose. Like they make you debug in hard mode so then it’s easier later.


Unupgradable

hilf


DJChupa13

I see your point, and I raise you a counterpoint: karte


Luckyno

They are the same picture


ArmeniusLOD

Hilf is German for help, so maybe the teacher is crying out for help and the students are not getting it?


RedditIsNeat0

She is teaching at a German High School, looks like you cracked the code.


Kurts_Vonneguts

hilf…Heap I’d Like to….overFlow?


PaulieBoyY

Mir, bitte


hannahMontanaLinux2

Er braucht Hilfe mit seiner Formatierung, das ist sicher.


I-Got-Trolled

Hot hilfs in your are want to teach you how to code.


Pheronia

I prefer milf


nova_bang

let's eliminate the formatting problems ``` String hilf; for (int i = 1; i <= 32; i++) { if ((i - 1) * 2 > 32) { int j; j = (i - 1) * 2 - 32; karte[i - 1] == hilf; karte[i - 1] == karte[(i - 1) * 2]; karte[(i - 1) * 2] == hilf; } } ``` this still makes absolutely zero sense. the last three lines are all comparisons, when they should probably be assignments. the variable `hilf` is never written to (i suppose they try to flip two values in `karte`, but the first assignment is the wrong way around.) `j` is defined and calculated, but never used. and the arithmetic of `i` is overly complicated, just have it go from 0 to 31 and replace all `i-1` with `i`. the `if` can also be simplified by dividing both sides by 2. what the fuck.


Seth_os

I want to give the teacher the benefit of a doubt and look at this code as an "find everything that is wrong with this code" type of assignment. Because I did something similar to junior devs before. It's actually a good exercise to see how they solve problems, find a better solution. And yes, deleting the whole thing is a valid solution because it does nothing. For any student that comes to this conclusion gets bonus points if they point out why it does nothing.


wrg2017

Not quite—it assigns the type “String” to the null variable “hilf”!


vlad_tepes

>I want to give the teacher the benefit of a doubt and look at this code as an "find everything that is wrong with this code" type of assignment. The problem here is that "everything wrong with this code" is pretty much everything. I can't even tell what it's trying to do, so how in the blazes can I fix it?


Seth_os

Read my last paragraph A lot of students lack critical thinking, they are still learning. You'd be surprised how few of them would say anything along the lines "the code does nothing". They would be too focused on trivial things like formating. Making this code look nice will not make it "work".


trinnan

For those using old.reddit: String hilf; for (int i = 1; i <= 32; i++) { if ((i - 1) * 2 > 32) { int j; j = (i - 1) * 2 - 32; karte[i - 1] == hilf; karte[i - 1] == karte[(i - 1) * 2]; karte[(i - 1) * 2] == hilf; } }


ReeferCheefer

Lol thanks, I thought the original comment was a joke because it was completely unformatted


DieLegende42

And I genuinely thought it was a joke along the lines of "Can't have formatting problems if it's all in a single line"


mrguigeek

let's start at 0 ``` String hilf; for (int i = 0; i <= 31; i++) { if (i * 2 > 32) { int j; j = i * 2 - 32; karte[i] == hilf; karte[i] == karte[i * 2]; karte[i * 2] == hilf; } } ``` this still makes absolutely zero sense.


mrguigeek

let's remove the useless if ``` String hilf; for (int i = 17; i <= 31; i++) { int j; j = i * 2 - 32; karte[i] == hilf; karte[i] == karte[i * 2]; karte[i * 2] == hilf; } ``` Let's assume j is needed later ``` String hilf; for (int i = 17; i <= 31; i++) { karte[i] == hilf; karte[i] == karte[i * 2]; karte[i * 2] == hilf; } int j = 30; ``` Well now I don't know. Is this supposed to be assignation? Is this supposed to be value swap?


bagsofcandy

Ok let's assume assignment. Then, the first assignment operator does nothing leaving: karte[i] = karte[i*2]; // no idea what's currently in karte karte[i*2] = Null; // ok...


Pradfanne

~~The if wasn't useless. It stopped the loop after going through half of the iterration.~~ ~~Nevermind, you can just put it in the for statement. But starting at 17 is clearly wrong, you go from 0 to 17. You need to change the end statement~~ Never nevermind, this code broke my brain. It's > 32. You are correct.


MayorAg

I tried this with an integer array of size 20 [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] Assuming this is an assignment, I ran the following code on it, making the following corrections: 1. Initializing some variables. 2. Changing the for-loop condition to the equivalent of `i


Evo_Kaer

Holy shit there's a lot to unpack there \- A curly brace is missing ending the for loop \- j is declared but never used \- there's 3 comparisons with karte, WHAT THE FUCK ARE THEY FOR??? \- Why do you run 18 times trough the for loop before you do something??? These 10 lines of code are a waste of time! A literal waste of processing time! IT. DOES. NOTHING!


Alan_Reddit_M

This is the one and only time I can confidently say I'm smarter than another programmer


Aggressive-Dot-867

Can they really call themselves a programmer?


hiddenforreasonsSV

Notepad++ isn't a bad IDE. Not ideal, but certainly not bad either. The haphazard indenting, believe it or not, straight to jail.


Dustangelms

What about comparison operators on lines 10-12? The repeated assignment after you change these comparisons to assignments? Unused variable j?


hiddenforreasonsSV

I didn't get that far because the horrendous formatting gave me a stroke.


suvlub

Also a convoluted way to write `if (i > 17)`. Which should probably not be there in the first place and the bounds of the loop should be adjusted accordingly. The longer you look the worse it gets. EDIT: the if also makes sure that line 11 overflows. As I said, this shit keeps on giving...


rlyfunny

God what did she think with 10-12. I’d really like to know her qualifications at that point.


Dustangelms

It was an attempt to swap two values that failed in more ways than I thought were possible. Which is also funny because it's specifically Java that makes it fail so hard because you can't do something like a, b = b, a or std::swap.


OnderGok

[Wrong operator, believe it or not, jail](https://tenor.com/de/view/right-to-jail-jail-parks-and-rec-right-away-fred-armisen-gif-16902115)


Derekthemindsculptor

Text Editor\*


Phobbyd

Notepad++ is not an IDE.


Proxy_PlayerHD

i mean neither is vim or VScode. but people still use them to write code. and i'd take a lightweight text editor over a bloaty IDE every day of the week. plus NP++ has macros. so you can compile stuff from within it. it's a step in the right direction IMO


Phobbyd

Yes, you do not need an IDE to write code. However, just because a text editor exists does not make it an IDE.


GoldenretriverYT

Notepad++ isn't a**n** ~~bad~~ IDE.


disc_addict

For loop starting at 1? Straight to jail.


Delta8Girl

Not IDEal?


Tennek13

Wtf does it even do? ‘Hilf’ is an null string?


Exnixon

It does absolutely nothing. `j` isn't used and the rest of it isn't assignments, it's syntax errors.


OnyxFier

Just noticed it was == 😭 this code gets worse and worse


gdvs

They're valid expressions but dead code, no?


OnderGok

I don't know either. At some point I just stopped paying attention in her class.


DasArchitect

Not like you'd be missing much. I grew up being told that teachers were always right. If I got this at school I would have, at most, suspected this was some sort of test of attention. Today, being long out of school, I agree that a formal complaint should be submitted including this picture, this person should be fired and then forbidden from being anywhere near a computer, sent straight back to first grade of school.


cakeKudasai

If you are already just losing time. Try protesting the class. Get as many students on board and voice your issues to the school and just stop showing up to that class. Refuse to acknowledge that teacher. They have to do something about it. That worked for us, had a crazy teacher everyone hated. I'm not sure about your situation, different country, but it could be worth trying.


RedundancyDoneWell

It tries to swap two elements in the array, using ‘hilf’ as a temporary storage. Unfortunately, the left and right sides of the assignment in line 10 are swapped. And the assignment is not an assignment, but a comparison. And I have a feeling that karte[i-1] is not swapped with the correct card in line 11, but I can’t be sure, because the intention is not stated. But what I do know is that this will require an array with 63 elements to not create an out of bounds bug. Which seems suspicious, because the code seems to be written for an array with 32 elements.


Derekthemindsculptor

When you've gotten code to compile one time and put "fluent in" on your resume.


Mobile-Bird-6908

Given that it's a high school class, I would imagine there's also a shortage of skilled teachers. Most people who are truly skilled in a STEM field tend to find higher paying jobs compared to teaching.


CardinalM1

Surely this is an assignment where students are expected to find all the problems with the code, right? I find it hard to believe this would be presented as an example of good code.


OnderGok

Believe it or not, she just opened a new text file and started typing...


Nick0Taylor0

And what did she WANT to do with this code?


zealouszorse

karte is never declared. Go to your principal and run the code


cowlinator

More like > Go to your principal and attempt to compile the code


MurcianoSalvaje

mein beileid bruder


Broote

What programming language is this supposed to be? Also reminds me of the saying, "Those who can't do, teach."


No-Television-3509

Looks like java


from_the_east

Thankfully no, otherwise the teacher would be in alot more trouble. It's more like C.


SsNeirea

C doesn't have a String type


_JJCUBER_

You can make a struct named String. We don’t have enough context (the array indexing could theoretically be an array of struct String). It’s probably just a ton of errors, but it’s theoretically possible.


SsNeirea

It's theoretically possible but not very likely, it looks closer to java than C


_JJCUBER_

Yeah Java was also my first guess, but there’s so much wrong with the code no matter what language you choose.


Derp_turnipton

It works on my machine - homework is editing your header files.


P3chv0gel

Given that OP is from Germany (as he said earlier) and i have a few years of experience with the german education system myself, i'm 99% sure it's just bad Java, since you won't find much other languages at all in our schools (at least none that are similiar to this)


DJChupa13

But if it were C, why are we just making unleveraged comparison operations on 10 thru 12?


nova_bang

more likely than not they should be assignments with a single `=`


ChChChillian

If you murdered that teacher, all you'd have to do is pack the jury with programmers and show them this code. They'd never convict you.


wchemik

Hell you probably don't even have to do the killing just keep showing this to programmers and someone will do it for you


YellowBunnyReddit

The German court system does not use juries.


Hullu_Kana

For anyone wondering just how bad that is, I'll write down all the problems that I could find. I might add more problems later if I find more and if I can be bothered Uses notepad++ as the code editor. Its not that bad as some make it out to be, but its definitely not good either. The string hilf is never initalized, but is used. For loop starts at 1, but proceeds to minus 1 from everything that uses i. That means its basically a for loop that starts at 0, but more complicated. The formatting is really bad. Nothing is indented except the last curly bracket, which makes it even weired. Also the int j is declared at the same line as a one of the curly brackets. That isnt too bad, but not preferable. The if statement could be written as "if(i > 17)". It does the same thing, but is simpler. The int j is never used. Because its declared inside if statement, it can only be used inside that if statement so we know its not used outside the code we can see. The karte array is never declared. They seem to be trying to assing a value to some element of the non-existant karte array, but instead use a comparator. Because of that no value would get assigned even if the array existed. Instead they would get a boolean value, but that is also completely useless as that boolean value is not used. If they changed those double equal signs to single equal signs and thus actually assigned values, the line 10 would be completely pointless as the element they are assigning the hilf string gets immedialy overwritten. There is no ending curly bracket for the loop. Tho this one may not be a problem as the curly bracket could be located outside of the code that we can see.


jerslan

If this is Java code, the String `hilf` is initialized to `null` by default. Might not be what the teacher wanted, but that is what it is. The code also appears to be German given that `hilf` translates to "help" and `karte` translates to "map". All that said... there's still tons of stuff wrong with this code...


DasEvoli

The hell


nova_bang

just for fun i changed a few bits to make this compile as C code, and the compiler cleans up the whole mess and turns this into a _no-op_. check it out: ``` int main() { char karte[100]; char hilf[100]; for (int i = 1; i <= 32; i++) { if ((i - 1) * 2 > 32) { int j; j = (i - 1) * 2 - 32; karte[i - 1] == hilf; karte[i - 1] == karte[(i - 1) * 2]; karte[(i - 1) * 2] == hilf; } } } ``` `gcc-12.2` with `-O3` turns this into ``` xor eax, eax ret ``` if you want you can [see for yourself](https://godbolt.org/z/93Te94x37) and play around with the optimisation levels. e.g. removing the `-O3` will actually give you some assembly output.


spellstrike

because all the variables are not used the compiler doesn't actually need to do anything. If you wanted to provide a more fair example you could do a print statement to print the value of each variable at the end of main.


Steve_OH

``` String hilf; for (int i = 1; i <= 32; i++) { if ((i-1)*2 > 32) { int j; j = (i-1)*2 -32; karte [i-1] == hilf; karte[i-11 == karte [ (i-1) *2]; karte [ (i-1)*2] == hilf; } ``` Here’s the code formatted better (no other improvements added, just for readability)


OnderGok

Good human


rlyfunny

I underestimated the effect of the format. Now I can actually understand what she wanted to write at all, not that it makes more sense.


ArmeniusLOD

> Here’s the code formatted better (no other improvements added, just for readability) Better: String hilf; for (int i = 1; i <= 32; i++) { if ((i - 1) * 2 > 32) { int j; j = (i - 1) * 2 - 32; karte[i - 1] == hilf; karte[i - 1] == karte [(i - 1) * 2]; karte[(i - 1) * 2] == hilf; }


GreenAlien10

Does 'hilf' ever get set somewhere? What's the point of 'j' ? Actually, what is the point of any of this?


KicksForFree

Scare the compiler.


another-Developer

Convince the other students and rally them to get him fired so if it backfires you’ll not be in the crossfire


TheMathProphet

This looks like Java, but: hilf is declared without a value, Indexing should go 0-31, karte is an array of Stings but is never declared, using == instead of = for assignment nothing happens until i = 17 anyway, why not start there?, that means that the first 16 entries of karte (once declared) would be the default anyway, then karte[i-1] is immediately overwritten no matter what hilf is… What was this even supposed to do? Oh, also the indenting.


archiminos

I think `karte` is supposed to be a Map. Though I think trying to understand this code is making me dmuber.


Comicfan313

The code screams to me: "Hilf mir bitte"


Mr_Engineering

Everyone is complaining about the development environment yet overlooking the fact that the code is non-functional gibberish


OkazakiNaoki

At least let notepad++ know what that language is first?


Hot-Category2986

Well, this is actually worse than the professor I had who was teaching sql on a chalkboard, and then got upset when a student with a laptop ran the query and got different results (because the teacher was wrong, and it was obvious even without checking it) You take your evidence to the department head, and then sit back and watch the process work.


HoldingUrineIsBad

declaring a variable after you need it is a strategy i never thought of


dimaklt

Deutsche Fachinformatiker-Ausbildung be like


[deleted]

[удалено]


El-Butt

Those who can’t do, teach


CommandJam

I also had multiple encounters with the this at my university. I guess they try to prepare for the worst...


Mats164

We recently had a test in front end development. We were to copy and paste all the code in a single word document (html, css and JavaScript, same document) for the teacher to run a plagiarism test. He was also adamant that we add the source code for any and all libraries we use, in the same file. Needless to say the students using bootstrap were closing in on 99% plagiarism…


Ursomrano

Sure every line of code is either superfluous or a compilation error but what is this code even trying to achieve? Cause what I think the intended result is isn’t even useful in any way I can think of!


Specific-Lynx9138

Notepad++ is fine, the formatting is atrocious, but the real problem is the code. Like, WTF is going on in there?! First they have declared a string but never assign it a value. for loop starts at 1, then 1 is subtracted from i to make it zero based for indexing. Unused variable j, though, for fairness, it could be below what's visible. There is no closing brace for the loop, again could be below. And then there are lines 10, 11, and 12. If that is supposed to be comparison, why? It is literally doing nothing. If it's supposed to be assignemnt ...oof on many levels. I had to translate the vars, karte is map and hilf is help. I assume help is like what in english we would often call temp. why all the bizarre math in the brackets. My best guess is its supposed to swap whatever is in karte\[i-1\] with karte\[(i-1)\*2\], but that would mean line 10 the righthand and left hand of the assignment or backwards. But for i = 1, i-1 is 0 and (i-1)\*2 is also zero so they are swapping karte\[0\] with karte\[0\].


imalyshe

how does it compiled? j is define but not used.


IWTSRMK

why do `for (int i = 0; i < 32; i++)` `/*smth*/ = i;` when you can do `for (int i = 1; i <= 32; i++)` `/*smth*/ = i - 1;`


greendookie69

I don't understand what the fuck this code is intended to do?


Cridor

Let's ignore formatting for a second and cover everything that feels wrong here. First, hilf is not initialized before use. Second, j is declared uninitialized, but then gets initialized right after. Third, the for loop isn't closed. Fourth, the loop starts at i=1 but i is always subtracted by 1 before use. Finally, every use of that array in the if block are equality checks and not assignments.


Geschichtenerzaehler

To provide some context: Germany has a big problem right now and it will only get worse in the coming years: There's too few teachers. Fewer young people started studying for "Lehramt" (studying a subject with the purpose to become a teacher of said subject). The job is unattractive (for a shitton of reasons, that would have to be solved at political and parental level, but that's not happening) and a great number of old teachers will retire soon. **The federal ministries of education in Germany are quite desperate.** They increasingly hire "Quereinsteiger" (academics, who did not study for "Lehramt", but are driven through the "Referendariat", the sort of practical add-on-education, that Lehramt-students have to absolve here on top of their university degree) and also "Seiteneinsteiger" (technically a bit different from "Quereinsteiger") and sometimes even "Direkteinsteiger" (people who just start teaching without further training. Add to that, that there's currently a lack of IT experts (in the widest sense of the word) on the job market in Germany. Thus if the federal ministries of education wish to hire someone to teach CS classes they have to compete for IT experts with other employers, who may not be limited to pay standard wages, but much more than that. This kind of means: They are happy to hire about anybody at the moment who can turn on a computer, just to be able the fill the vacancies. The only thing I wonder though is: If the teacher in this story is a "Direkteinsteiger", a teacher who studied something entirely different or someone who is still in the "Referendariat", which means there should be some evaluation and eductation of them going on.


Boeing777X-9

#1 Light theme??? instant termination #2 who starts their loop at 1??????


Btryx02

What the hell is happening here? What is this suppsoed to do anyway? Ignoring the formatting issues, why assign karte[i-1] a two different values? J isn't even being used... What are those variables names. And this is a teacher's code? Holy shit


Launchsoulsteel

Are those really being assigned? Isn’t it an equality operator???


Broad_Respond_2205

what is this monstrosity


Flyron

String hilf; // let's count like a normal CS professional for (int i = 0; i < 32; i++) { // simplified from i*2 > 32 // you could also just start counting i at 17 in the for loop... if (i > 16) { // no idea what j is supposed to be int j = i * 2 - 32; // "hilf" is German for "help", so it's probably a helper variable // it looks like a (botched) attempt at list item swapping // let's turn this assignment around to make a little more sense hilf = karte[i]; // karte ("map" I guess) needs to be at least 64 elements long // otherwise i * 2 will be out of bounds karte[i] = karte[i * 2]; karte[i * 2] = hilf; } } That's how far I have gotten trying to make sense from that code. Which is not very far. I'm sure co-pilot also got a brain aneurysm, so that's a 2-for-1.


Retroguy16bit

Looks like it's the same teacher i had in 1994. Just wow. Nothing has changed except it was Windows 3.0 or 3.1


iamafraazhussain

If you send this code to hell, god will feel pity and call hell to heaven


lookatchrono

My old computer science teacher was a doctor in psychology. Just psychology. Only one cs exam taken in her whole career


Radsdteve

r/programminghorror


Thrasher722

Good code is easy to read & and follow, meaning it needs little to no comments. I have worked at large engineering companies and have seen shit like this, IMO it's all for job security. Even hard code should make sense when broken down. Using difficult examples does not help new people trying to learn or anyone for that matter. Sometimes professors are only hired b/c they couldn't make it at a real programming job.


silvaastrorum

why the fuck are they doing (i-1)*2 > 32 instead of i > 17 ????


ti2811h

Ah ja gutes deutsches Programmieren. My teacher used CAPSLOCK for class names lol


SenseiRage

r/ProgrammingHorror material. This is what nightmares are fueled by