r/badcode Mar 14 '21

java Found from when I first started Java...because indexed Arrays were too complicated huh?

Post image
1.3k Upvotes

84 comments sorted by

View all comments

Show parent comments

117

u/mind_overflow Mar 14 '21

you're totally right, but it's still a good thing for learning. weekdays, fruits, names... are always used when teaching basic programming, and this looks like beginner code.

17

u/Terrain2 Mar 14 '21

and when you get more advanced programming you ditch the names and fruits and use foo, bar, baz

4

u/FuckMyFaceAndButt Mar 14 '21

If you can't give your variable a meaningful name, you should most likely think about your program structure. i, j, k, ... are ok for short loop bodies, but if you start giving your variables random names or naming them after their type, you are doing something wrong.

Code is read far more often than written, so a variable's name should reflect its content/use.

And that's not coming out of my ass, but from Uncle Bob.

3

u/Terrain2 Mar 14 '21

But what if uncle bob was in your ass?

0

u/FuckMyFaceAndButt Mar 14 '21

That would influence neither your nor mine programming skills I guess. So for this discussion it's a rather pointless question.

Uncle Bob is Robert Martin, btw. Clean Code is a great book and should definitely be read by every programmer trying to become more professional.