MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/msv49l/when_your_teammate_refactor_your_code/guvz3cs/?context=3
r/badcode • u/Bence675 • Apr 17 '21
216 comments sorted by
View all comments
772
I would rewrite it as
If (!condition1) do_anything2() Else if (condition2) do_anything1()
255 u/MightyMeepleMaster Apr 17 '21 The original code was fine because it was fairly easy to read. All other variants posted here are more compact but also more confusing.Either way it doesn't matter. Any decent compiler will generate the same object code regardless of how you write it. 47 u/dyingpie1 Apr 17 '21 I think it depends on the context, such as whether condition2 and condition1 are edge cases.
255
The original code was fine because it was fairly easy to read. All other variants posted here are more compact but also more confusing.
Either way it doesn't matter. Any decent compiler will generate the same object code regardless of how you write it.
47 u/dyingpie1 Apr 17 '21 I think it depends on the context, such as whether condition2 and condition1 are edge cases.
47
I think it depends on the context, such as whether condition2 and condition1 are edge cases.
772
u/dyingpie1 Apr 17 '21
I would rewrite it as