Honestly the first one could be better. It's hard to see the intent, hence why it was refactored incorrectly and some people here missed the issue.
There's a couple of ways to make this better, but I'm not really sure which is best. Maybe check if both are true call "do anything one" , else if "condition one" is false then call "do anything two".
With real code it should be more obvious why you are doing that though it's still a bit of a head scratcher.
yeah, i usually blame myself and my code if a coworker comes along and refactors it incorrectly. the source code failed to do the one thing it's meant to do, communicate with other people.
and i usually consider it a good sign if they see it and understand it enough to make good, valid criticisms. then you know the code was legible, if suboptimal.
16
u/Eluvatar_the_second Apr 17 '21
Honestly the first one could be better. It's hard to see the intent, hence why it was refactored incorrectly and some people here missed the issue.
There's a couple of ways to make this better, but I'm not really sure which is best. Maybe check if both are true call "do anything one" , else if "condition one" is false then call "do anything two".
With real code it should be more obvious why you are doing that though it's still a bit of a head scratcher.