5 ms·
Most people hate const at first (myself included) but once you get used to it, it really does reduces mental load. Not having to glance around is precisely the
by gintery 6y ago
Most people hate const at first (myself included) but once you get used to it, it really does reduces mental load. Not having to glance around is precisely the point, its not a big thing but it does help.
- xfs 6y agoI stopped using it for locals after it increased my mental load. The maintenance cost of const for all local variables is huge during refactor like you're fighting it just to get things done. And in most cases where the type of a variable matters I do have to glance around like when I need to remove a variable or change its type or refactor its dependent variables so const doesn't really for those cases.
- danielscrubs 6y agoSo you prioritise the writing of the code instead of the reading. In that case, it makes sense.
- gintery 6y agoIf you have to assign to a const variable during a small refactor, then maybe it shouldn't have been const in the first place? I'm struggling to imagine examples where this is a real problem