DEV Community

Discussion on: How much should you refactor names when domain terminology changes?

Collapse
 
kspeakman profile image
Kasey Speakman

I tend to take naming pretty seriously. I'm as bad at naming things as the next person. But when I do finally stumble upon the right name for something, I go back and make it consistent in the code.

The main reason I do this is because naming is a real problem in our legacy code base. More than once I have completely misinterpreted some old code because of the names that were used. For example, it is pretty common in our code base for an array of something to be named as a singular -- the variable is named customer but it is actually a list. Or vice versa -- customers is actually a single Customer. Or data types are named for the effect they are intended to have instead of what they are -- a type containing customer data is called Email because the data is intended to be used for emailing. So now it is a personal goal of mine to fix bad naming whenever I see it, and suggest alternatives to poor naming in code reviews... because it is a problem we definitely have.

Maybe not directly addressing your question... for actual domain code, I would be quite inclined to rename things. But as with everything, you have to weigh the cost. As @alainvanhout said, if naming changes are very frequent, it makes little sense to continually go back and rename. I would probably make a story to collect the name changes and perform a batch of them at once.