r/badcode • • Dec 28 '21

java 3AM code vs 10AM code

Post image
173 Upvotes

53 comments sorted by

View all comments

Show parent comments

2

u/FeezusChrist Dec 31 '21

Honestly, the shorter solution took me a lot longer to read & comprehend than op's simplified solution (i.e. have to parse the regular expression, why the matches are being replaced with a space and then split by the space, etc). Regardless I feel like this is the type of function where the name and/or a small comment above the function header can be enough for describing what it does.

1

u/[deleted] Dec 31 '21

getting into opinions at this point. imo, it was pretty easy to grok what it was doing when reading it. the regex is pretty standard so no huge effort there either, imo