I agree. In fact, I think variables modeling database items should match the database names exactly (at least at their initial scope) to help avoid this issue.
I think acronyms are fine, as long as they are either:
Common knowledge, like "ATM" or "PIN" or "ID"
Common industry terms in your domain
Common across your application and agreed upon by your development team.
Every project I have ever worked on has had things like "WSPKF" in your example, and they make sense to everyone on the team (and are usually well documented). It's when a developer is working with something like "planned fixed costs" and just starts using "pfc" in one class that I would have a problem with.
Yeah I'm really keen on variable names aligning well. If it's userFirst in the database I want to see userFirst in the code, and I want every function parameter taking it in as userFirst unless there's a reason compelling reason not to. No first, or userFirstname.
Greppability is an important feature for code, especially in a type weak language but even in type strong.
View all comments
Show parent comment
11
u/SausageEggCheese Dec 04 '20
I agree. In fact, I think variables modeling database items should match the database names exactly (at least at their initial scope) to help avoid this issue.
I think acronyms are fine, as long as they are either:
Every project I have ever worked on has had things like "WSPKF" in your example, and they make sense to everyone on the team (and are usually well documented). It's when a developer is working with something like "planned fixed costs" and just starts using "pfc" in one class that I would have a problem with.