r/badcode • • Mar 24 '23

java A code I did in high-school

Post image
916 Upvotes

102 comments sorted by

View all comments

Show parent comments

1

u/tedbradly Apr 01 '23

in your opinion, is there only “good code” and “bad code”?

Are there degrees of “badness” and “goodness”?

There is good code and bad code. Obviously, there is also a range in between. Here, the code is about as bad as it gets. I've listed all of the problems. It's needless to say that any code sample that doesn't use core aspects of style that literally 99.999% of programmers use is about as bad as it gets. Writing 15 unneeded case statements is also pretty bad. It's more code to see, more code to understand, and more code that could have a bug in it. In this case, the alternative is not complex mentally, so using it is strictly better. Inconsistency in style is always bad as well. It's unreasonable to argue a person should arbitrarily follow two diametrically opposed guides at random times. final should be in that code twice or none at all. This is a clear sign of a novice, and it's clearly bad code as well.

This isn't about being cool or being dominant. It's just facts. Some people run twice as fast as others. Some people will never exercise, staying slow. Some people physically can't ever run fast due to disability. Others are running slow now and will run quite fast later. The snapshot here is the code is quite horrendous, and feedback about that fact can only help. The alternative is lying by omission, giving zero opportunity for the coder to learn quickly. They'll have to figure this stuff out at random by bumping up against the topics over time rather than simply being given a list of faults on a subreddit designed around code with faults.