2

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 ?

5
  • 2
    Go to your Boss and call him Pal. :)
    – rvs
    Apr 1, 2011 at 18:57
  • 1
    $this->get_user_friends_or_buddies_or_chums_or_mates_maybe_pal_or_crony_or_something_like_that(); Apr 2, 2011 at 18:27
  • Either add constructive comments or just don't. Apr 2, 2011 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. Feb 24, 2012 at 4:04
  • Or put another way... GALIYWMTWWY (Get a life if you want me to work with you). Feb 24, 2012 at 4:05

2 Answers 2

3

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.

0

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.

1
  • 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... Feb 24, 2012 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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