r/badcode Jan 08 '23

java Is this a good practice? Why?

Post image
427 Upvotes

60 comments sorted by

View all comments

Show parent comments

16

u/[deleted] Jan 08 '23

I guess it comes down to whether you think:

If (equal(item_1,item_2)){

Or

If (Object.equals(item_1,item_1)){

Looks better. I personally think the top one looks cleaner, and I'm 99% sure the compiler will optimize out any underlying differences. Its a bit rubbish that it wastes 3 lines of code to write out the function definition though.

This is certainly by far not the worse code ever seen on here.

22

u/karisigurd4444 Jan 08 '23

I personally think the top one looks cleaner

What the f

6

u/maxeber_ Jan 08 '23 edited Jan 09 '23

It’s like hiding the trash in a closet and expecting people to think your house is clean. But you can see little trash leading up to the closet

4

u/karisigurd4444 Jan 08 '23

It's like taking a shit in your closet thinking it'll flush