Question on understandability of code: How long can a variable name be?
I'm in a C++ class that has put emphasis on understandability (the ability for other users previously unfamiliar with your code to be able to decipher and edit your code).
Additionally, we were instructed that long variable names can be confusing and should be avoided as well.
My question is, are my variable names too long??
I've got to name three separate variables that are all years.
They are all in different centuries, thus I have them named:
Code:
int seventeenth_century_year, eighteenth_century_year, nineteenth_century_year;
Grant it, I could use the "downhill effect" of C++ coding to my advantage, and just
make the int named year and re-establish its value further down the code as needed because nowhere in the code would 2 different year values needed to be calculated together. e.g.
Code:
int year, var2
year = 1700
var2 = sqrt(year)
//outputs
//outputs
//outputs
year = 1800
var2 = sqrt(year)
//outputs
//outputs
//outputs
year = 1900
var2 = sqrt(year)
//outputs
//outputs
//outputs
Note that there is no user input in this program, so the variable value cannot be manipulated that way.
(This is a school assignment for an intro C++ class, and the overall goal is to improve our development of algorithms pre-coding.... Not so much to improve our ability to code)
Thanks in advance!