I am working on project that is near completion that handles a business’ client information. Amongst the plethora of variables, there are: main_phone cell_phone and office_phone to store various phone numbers of a client. These variables are used all over the project.
The client has asked that we display them as Phone 1 Phone 2 and Phone 3 instead of Main Phone Cell Phone and Home Phone. Their reasons for wanting this change are reasonable.
My question is, would you comb the whole project and change all the variable names (many locations across the project) or simply change how the variable is displayed to the user (one location), and not the underlying variable name itself?
I feel like the latter option is poor style since the variable name no longer explain the data stored within that variable.
Your thoughts?
Thanks
Honestly? I would replace three variables:
main_phone,cell_phoneandoffice_phonewith one:phonesof array type. Since the phones are indistinguishable, why keep three distinct variables? Just callphones[0],phones[1], etc. This is also a better design when relational databases are taken into account.Another benefit is the ability to seamlessly add fourth phone if it ever becomes a requirement.
For the future consider wrapping
phonesarray intoPhonesobject/structure. Better encapsulation will prevent such massive changes required when requirements change (see: shotgun surgery).If you can’t afford to perform such a huge refactoring, you should change the names to reflect the meaning. If you are using statically typed language, this is fairly simple and safe. Otherwise clever regular expression should do the trick.