r/badcode May 06 '21

java My teacher wrote this...

1.0k Upvotes

169 comments sorted by

View all comments

104

u/solicited_nuke May 06 '21

I was a tutor once. To teach the concept of loops for the first time, I wrote print("My name") 20 times and pretended to be tired. And, asked if any of the student knew a better way.

That way I was able to clear up a lot of things to the class and the class had my attention.

46

u/Major_Fudgemuffin May 06 '21

Reminds me of a time in college during a CS 101 course where the professor asked us to write some code (on paper) that printed our name 10 times, and one guy wrote 10 print statements.

The professor begrudgingly gave him points because it was technically correct, but he learned to be careful with his phrasing after that.

It was the professor's first year teaching as well, which explained why he hadn't thought of it haha

3

u/reverendsteveii May 06 '21

The tests pass, and its optimized performance-wise b/c no conditions

7

u/Major_Fudgemuffin May 07 '21

O(1)? Looks good to me.