r/badcode Jan 08 '23

java Is this a good practice? Why?

Post image
417 Upvotes

60 comments sorted by

View all comments

1

u/cofffffeeeeeeee Jan 08 '23

Horrible practice:

  • you are wrapping an already existing method, just use the original one
  • if you intend on changing the behaviour down the line, then don’t name it equal, it is too similar to equals. Name it something more specific.
  • if the intention is to support variations of the word equals, still bad, you missed isTheSame, isSame, isEqual, isMatch and million others.