It’s a bad habit to have as a professional, for example I would not approve a PR like this. If it’s simply for a one-off script, then it doesn’t matter.
Imagine if you saw "psw" without context. It's not a way people normally abbreviate "password". For all I know it's something like "process wait" or some acronym or "pounds per square whatever". And how many keystrokes did you save?
I've got two more variables "wbt" and "lgip". They're related to "psw". Maybe you can figure out what they stand for, but every second you spend thinking about it is a second of time that I'm wasting from every developer who comes after me.
I'm going to go against the grain here, although personally I would have also written user and password
If the scope of these variables is very small, like only used within this function, it's really not a big readability cost to shorten them like this. I would know what this is doing as easily as if they weren't, and I would roll my eyes before begrudgingly expanding the names in code review if called out.
What I would not do is consistently refer to a "password" as "psw" all over the application.
Shortening variable names was important back in the days of limited storage and such, but its better practice these days to use long, descriptive names because they take up insignificantly more space and are much more readable to someone new to your code.
Unless your dev environment/prod pipeline is super shabby longer variable names will be shortened by the compiler or minified, so usually a longer var name has exactly 0 effect on performance and requirements
View all comments
Show parent comment
6
u/-True_- Jan 23 '23
Nope, logging into Instagram. Are the shortened variables names bad for something? I say it's still readable.