views:

561

answers:

11

We've all been there. You have written some code and unit tests, the tests all pass, and the code is decent (nothing's perfect, right?). Then, someone who is sure that they know better than you comes along and decides to change your code or the interfaces to your code just because he/she does not like the variable/class names that you used. No "real" refactorings, no real optimizations, no real improvement -- just different words -- not necessarily better words, just different.

My real problem with this is that (a) its a waste of time and (b) it shows a blatant disrespect for the fellow developer that wrote the code in the first place.

My visceral response is to lash out, but that's counter productive. Instead, I though that I might wright a paragraph or two as sort of a "Charter" or "Philosophy" that is adopted for the project. I'm wondering if anyone else has tried this, and if so, was it successful?

After looking at the initial comments below (which are appreciated), I think that my problem is primarily that this change broke the build for code that was already working. So time needed to be spent to fix the code for what was (in my opinion) a non value-added change.

-- Thanks

+17  A: 

One thing that might help in this sort of situation is to require code reviews for all changes. People are less likely to make pointless changes if someone else has to review it first. If they can actually convince another developer that their change should go in then maybe it isn't so pointless after all.

Laurence Gonsalves
It is also possible that a code review might have shown that the original naming or original code had issues...
Tim
I suspect that paying more attention to code reviews and opening these discussions to the group will likely do the most good -- Thx.
Steve Hawkins
+1  A: 

Sometimes, changing names might be justified. It can be confusing if half the project refers to a person's sex, and then you check in some new code that refers to gender or something. Okay, this might be a bad example as technically they are two different things and their meaning is most likely still obvious. But if a project's code uses two different terms to refer to the same concept, it can be confusing.

Usually I try to leave people's code alone, unless I have some justification for refactoring. Luckily the same seems to go for my colleagues, so no, I have not had the need for writing such a charter yet.

Thorarin
+20  A: 

...decides to change your code or the interfaces to your code just because he/she does not like the variable/class names that you used.

My real problem with this is that (a) its a waste of time and (b) it shows a blatant disrespect for the fellow developer that wrote the code in the first place.

My visceral response is to lash out...

I see some VERY CONCERNING things in those statements.

  1. naming is REALLY, REALLY important. It is worth rewriting code to get it correct.
  2. It is not YOUR code
  3. How is it disrespectful?

You are taking it too personally.

I once worked with someone who freaked out when I made changes to "his" code. His code as horrible; it was buggy and unmaintainable. He was always staying late, fighting fires and breaking things - basically a negative contributor. I rewrote all his bad code for a big piece of functionality for a project one weekend and when he came back in on monday had a hissy fit. I am not saying your stuff is horrible, but maybe you need to calm down and be more objective about it.

Don't take it so personally. Step back and think about it - maybe "your" code needed fixing

We might be able to give better answers if you posted the code and changes, or at least some better idea of the situation with an example or two.

EDIT: After seeing the code change and finding out that the build was broken, I am going to have to change the tone of this answer. I understand Steve's frustration - and i agree - that is not a good change. It makes a specific typedef more general and not very descriptive any more.

While I think some of my points are valid, in this case it looks like the changes were not appropriate.

The issue of code "ownership" is irrelevant. If the code changes are useless then everyone on the team should not be happy. If they are good changes then everyone should be happy about it. If there is a difference of opinion then you all need to find a common ground.

Breaking the build is not a good thing.

Steve, sorry if I came down harsh - it looks like in this instance you are justified in your frustration, but not because it is "your" code.

Tim
Err it is disrespectful to change somebodies code without talking to them first about the changes and explaining the issues with their code. Going ahead and dumping all over their code is a sure way to piss somebody off... how else is somebody meant to get better?
Jon
Um, last I checked, the code was my employer's, not mine or my coworkers'. I'm not sure what "dumping all over their code" means. It would help if we got real information about the changes, but for now it is speculation. But I stand by my assertion that it should not be taken personally and some of the OP's comments scare me. I would have a serious issue if he was reporting to me or in my group.
Tim
+1. It's not *your* code. It's work for hire. If it were your code, no-one else would be able to get at it.
paxdiablo
Agreed, I took the changes personally. I did not feel that they added any value, and they broke the build. If the person that made the changes had actually followed through and made sure he had fixed all of the the code and he had broken (see addition above for the change), and re-run the tests, I don't think that it would have irritated me nearly as much.
Steve Hawkins
Agree with tim and Jon. If code could be better, it should be fixed. But here are two points: 1) you fix someone else, which means he mistaken. If he agree with this, so no problem. But if he think, that everything is ok, you can just fix this code without discussing your fix. In short people don't like they are fixed. 2) Your fix must make the code better, which means that you should talk about this at least with code author.
Kamarey
Making a non-function changing, rename-only code change is one thing - it's impossible to tell without specifics whether it's a good or bad thing. Making a naming-only change and *not bothering to see if they broke anything* is a bit scary. If you're that worried about the quality of the code, wouldn't you at least run the tests? BTW, I feel that the original name was better - it explains the purpose of the variable rather than just the type.
kyoryu
@Steve, If he broke the build that is not a good thing, but it is a different issue than changing "your" code. That is irrelevant. Breaking the build is another matter.
Tim
A: 

I agree with Laurence that code reviews might help. This is an issue of how your team should work together. What might help is the notion of Egoless Programming - in a nutshell, considering the code as a joint product of the team, and trying to make decisions for the sake of the code rather than because of the programmer's ego. Your teammate violated the fourth commandment of egoless programming - "Don't rewrite code without consultation." Maybe if your team is made aware of these principles, things will improve. I would try this.

Yuval F
+4  A: 

In any software development team with a size > 1, standardization is key. Not only for each developer to understand the other's code, but so that the people that come along in 2 years, 5 years and 10 years can look at any part of the code and see a clear and consistent pattern. Will you... and the rest of the team... seriously still be there, working on this project, years down the line?

If you both "just have your way of doing things" and there is no formal standard for the project/company, I suggest you work with the team and/or your boss to suggest a formal standard be adopted. There are many standards already published for the various environments that you can use either as the standard, or as a starting point.

If there is a formal standard, everyone on the team is obligated to follow it... no matter how much "better" they think their way is.

So much for the hard skills.

Now on the soft skills side...

You and your colleague need to develop a healthy relationship, or decide to work in different places. Tit-for-tats that result in people feeling that they want to lash out will make everyone unhappy, not to mention gravely jeopardize the project everyone is being paid to complete. Look for a person you both respect (maybe your boss, maybe a respected and level-headed senior member of the team, maybe HR if you have a good HR department). Explain to that person what the problem is and that it makes you feel unvalued and disrespected. Ask for help talking through the situation with your colleague and agreeing to a better way of working together.

Finally, you need to be open to the possibility that your colleague may be making subjectively correct changes, even if the manner he's doing it in offends you. Separate the correct coding from the correct interpersonal interactions. Do the right thing for the project.

Eric J.
I agree with everything you said with the proviso that it applies to teams of size=1 as well.
paxdiablo
Good point.I certainly standardize my own individual work as far as possible and build a well-structured library of reusable code, following a consistent design pattern. So yes, a good idea for a team of one as well. Still, if it's just one guy, he knows what he was thinking (sometimes), so I guess you *can* succeed without standardizing your own work. You *certainly* make it much easier on yourself if you do.
Eric J.
+7  A: 

Heey,

Guys! WE all need TO TALK!

Just sit together and TALK! There are always reasons to change and there are always reasons NOT to.

Decide together!

Don't just go to StackOverflow or a forum and say ask this kind of questions.

The new dev does it - he gets responses from community probably positive (yeahh, bad code should be refactored).
The current dev does it - he gets responses from the community too: "What an idiot could do such kind of changes!"

And the result is: Counterproductive, destructive, offensive environment for a long time.

Who wants it?

Just put your arguments on the table and that's it.
New dev needs some introduction too.
Old dev needs to listed TOO.

This should be collaborative work AND not pissing each other off.

Decide together, talk, as THE TEAM.

And... better ask questions like "How is it better to refactor this?"

Cheers.

Dmytrii Nagirniak
+1: More succinctly - don't try to use StackOverflow as a lever for getting your own way in project disagreement!
Stephen C
A: 

How about using an automated build system, so when this person changes the code and breaks something the team will get an alert about it. This solves your problem with having to waste your time fixing something broken by someone elses change to your code. This way everyone will know that so and so made a change and broke the build, and can see for themself. The rule is "dont break the build".

sylvanaar
And the next time that guy will wait for you to break the Build and use a "Reply To All" on the Email.
Geek
An automated build failure email? The emails usually cannot be replied to. Evenso you breaking the build at some future point and their response are not relevant. Your worry that he would "reply to all" shows that your problem has nothing to do with the code at all - the code is just a battlefield on which you are waging a war.
sylvanaar
+1  A: 

You should be discussing this with the person who did it, in a non-threatening manner.

Imagist
+2  A: 

Well if that guy is going to maintain your code, let him do whatever he wants to. Just remember that it is not "your" code. The code belongs to the company for which you work for. You wrote the code and you got paid for it. Let the Management do whatever they want to do with it.

Don't take things personally, move on.

Geek
A: 

I believe every developer should take responsibility and hence own some of the code, but not all of the code. I understand the code that I've written better (irrespective of how good/bad it is) than any other guy that has ever seen it. Therefore the changes I make will be faster and less prone to error.

I don't mind anybody changing the code I've written later on, but I have a couple of conditions:

  1. If you change the code and that causes something else to break, you are responsible for fixing it, not me.
  2. If I don't agree with the changes you made I will change it back to the way I want it since I have to take responsibility for this piece of code in future.

Not all developers should be making changes to all the code, all the time. Only some of the time, for the purpose of getting to know the code (sharing knowledge).

I've never worked for an employer that endorses a "everyone can change anything any time" policy. Developers own certain parts of the code and they are asked specifically to make changes/refactor based on a development democracy.

You touch my code and break something, (1) you better have a good reason for the change that all developers agree with and (2) you better not leave broken things broken or ask me to go do the clean-up for you UNLESS you're my superior. I will humbly submit if that's the case.

Maltrap
A: 

Perhaps not completely on topic, but .... If you have developers who have the time to make changes to code just because they don't like the variable names used, then maybe the conversation should be about whether you have too many developers and which ones should be shown the door ... or how you're going to justify to management the bloated staff you have, especially in the current economic circumstances!

PTBNL