DEV Community

Discussion on: array.map(): A better way 🧐 ?

Collapse
 
andrewbridge profile image
Andrew Bridge

I think there's a balance to be struck in terms of maintainability when naming variables. Sure, overly verbose variable names are clunky and can make things harder to read, but on the other hand revs and rname a) gives me no context (is revs something about revolutions?) and b) can be easily misread (looks a quite similar to mame).

I think with IDEs, things like typos become far less of a problem, so I'd personally stay away from lots of abbreviations.

I also think that this specific task fits quite well with your suggestion of what .map() should be used with. It's short, single manipulation and, with proper naming and shorthand functions, is quite succinct:

reversedNames = names.map(name => name.split('').reverse().join(''))

Collapse
 
sereneinserenade profile image
Jeet Mandaliya

I also agree with you that with the modern age of IDEs and linters, typos have become far less of a problem unless we're doing something over ssh on a raspberry pi and have to use vim or nano. But if I am to do real programming on ssh, I would prefer using vscode remote containers mode and code there rather programming in vim / nano on over ssh.

Thread Thread
 
andrewbridge profile image
Andrew Bridge

Don't let the vim enthusiasts hear that! You'll be stuck for hours as they tell you the 9000 ways of making vim fully sentient and writing the code for you haha!

Thread Thread
 
sereneinserenade profile image
Jeet Mandaliya

True to that. I've done that many times myself as I am a big VIM fan and even use VSCode vim mode today. I've used it as my main developing software for a year but the problem begun when I started working professionally as a fronend dev, other people were using .editorconfig and prettier and stuff which I found were a bit ( for me ) cumbersome to implement and therefore I switched to VSCode. Though my love for Vim and it's ways to handle things is eternal.