Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Let us say I am writing a Facebook like application.

I write code like below

$this->get_user_friends(); 

then next morning the boss says that we don't want to call Friends friends anymore, we will call them Pal.

Then all the templates are changed but what about the code above? After 2 years when some programmer will have to look into it he is likely to get confused isnt it ?

What do you guys really do ?

share|improve this question

migrated from stackoverflow.com Apr 2 '11 at 9:57

This question came from our site for professional and enthusiast programmers.

2  
Go to your Boss and call him Pal. :) –  rvs Apr 1 '11 at 18:57
    
$this->get_user_friends_or_buddies_or_chums_or_mates_maybe_pal_or_crony_or_somet‌​hing_like_that(); –  thorsten müller Apr 2 '11 at 18:27
    
Either add constructive comments or just don't. –  Akshar Prabhu Desai Apr 2 '11 at 20:55
1  
Akshar. A sense of humor helps in programming too. I really laughed at the above. Some folks in this industry take themselves WAY too seriously - I recently said to new co-workers when out for lunch (food that is, tee-hee) and I saw a cool cloud formation I said "cool clouds" the reponse from three other folks was 'huh? new cloud storage?' I kid you not. –  Michael Durrant Feb 24 '12 at 4:04
    
Or put another way... GALIYWMTWWY (Get a life if you want me to work with you). –  Michael Durrant Feb 24 '12 at 4:05
add comment

2 Answers 2

up vote 3 down vote accepted

First, you need a code refactoring tool. That will help you to change the names without bothering about validity of the code as it will be checked by the tool.

This kind of problem where names change happen all the time, and it's a good idea to make sure you concepts in code does match the domain-specific concept. Most of the time you'll not get it on the first try so always assume that names could change.

That's why refactoring tools exists, and that's why it's really important to have one.

Second, if you can't use a refactoring tool, you then have two options :

  1. Do the refactoring at hand, then as suggested by Marco, you should first evaluate how much you have to do and make sure it is possible with your current resources (aka time aka money).
  2. Don't change the code. That will work for a short time but later it will make harder to get into the code as you'll have to REMEMBER the indirect names of the changes contexts. Naming concepts in codes is exactly done to not have to remember about them, you read them and you (should) know what it's about. So avoiding any mental weight on code knowledge is really really important, particularly if the codebase is big and/or if you'll get to another project and comme back to this one later - will you remember? So if you decide to not change the code, make sure it's temporary. Relying on experience I would do 1. anyway because most of the time temporary code becomes permanent...

So, change it anyway, your future self will thank you.

share|improve this answer
add comment

I think you should consider if it's worth the cost of time, but generally it is. Simply renaming a function should take 5 minutes or so. Wipe away the confusion could take more time.

share|improve this answer
    
I agree with this and Klaim's note. However getting buy in from management that don't understand (so haven't been educated/experienced) the need to avoid this kinda technical debt is a whole 'nother challenge... –  Michael Durrant Feb 24 '12 at 4:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.