Skip to content

Conversation

@mbonaci
Copy link

@mbonaci mbonaci commented Oct 29, 2016

No description provided.

@dmitriz
Copy link

dmitriz commented Dec 7, 2016

Why is this an improvement?

@mbonaci
Copy link
Author

mbonaci commented Dec 19, 2016

Isn't it a bit cleaner?

@dmitriz
Copy link

dmitriz commented Dec 19, 2016

Not to me. If arg is cached and nothing is to do, I'd like to get it out of my way first. That makes it more scalable as all changes would go below.

@ulpian
Copy link

ulpian commented Apr 6, 2018

Why would scalability be an issue with this improvement?

@huyz
Copy link

huyz commented Apr 7, 2018

The original code requires less cognitive load when reading. Once you get one condition out of the way with an early return, you avoid having to keep two conditions simultaneously in your head while reading the rest of the function (and making sure you understand it and it is bug-free). So "cleaner" (i.e. less repetitive) doesn't imply "easier to read" and "easier to debug".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants