ide / react-native-button

A button for React apps
MIT License
773 stars 129 forks source link

Minor code style update #54

Closed Zidail closed 8 years ago

Zidail commented 8 years ago
ide commented 8 years ago

I don't find these changes to improve the code, sorry.

Zidail commented 8 years ago

No problem @ide. Just out of curiosity, could you tell me why you'd prefer to keep them as lets rather than swap them to consts?

ide commented 8 years ago

const doesn't really offer more than let in this case. At the level of individual functions it's not a problem to see if something gets reassigned or not, your brain has enough "RAM" to think about the whole function without const vs. let being that helpful. So then I find that mixing const and let in the same function makes it harder to read because syntactically there's extra visual complexity because const and let are different lengths -- one study showed that visual alignment of code was one of the things that makes it easier to read -- and if you make a change to the code in the future that adds/removes reassignment you need to change const to let or vice versa and I find the cost of that thrash higher than the benefit from the info that const or let communicates.

Zidail commented 8 years ago

Thanks for taking the time out to explain this. I see what you mean. It's always good to hear another developer's perspective.