tags:

views:

287

answers:

9

I am trying to remain positive and keep the objective of quality software as my goal; however, others are criticizing my code. How can I prepare adequately and get the most out of a code review that may be rough?

+4  A: 

Programming style is like a girlfriend (boyfriend). Everyone has his own, and for him (her) she (he) is better than the other's.

Therefore, don't prepare defensively for criticism. Acquire it, and learn from it. Even the most blatantly wrong person can have good ideas (yes, sometimes you have to invoke the broken clock effect: a broken clock is right twice a day).

Moreover, my experience dictated me that there's no good solution in programming. There are compromises. Your solution could be good, and his solution could be good as well. It's rarely like your is good and his is wrong. Maybe one of the two solutions is clumsier for that kind of design, and eventually if you find a valid reason for this to happen, then you can point it out.

Stefano Borini
+1 for the broken clock effect :D
Peter Perháč
+1  A: 

I'm not sure there is a way to keep it from hurting. The important thing is to keep learning.

dicroce
+2  A: 

Listen to what they said and learn from it. make sure to write down what they said you had wrong in your code and make sure from that moment on to always use it when coding that way your code will eventually improve and you are going to get to a point where there are no defects found or no major ones at least.

Annerajb
+2  A: 

Like Stefano said, don't be defensive, be proactive. Go over your code before the review and see if you can find things that you could have done better. Make notes of the things that you know you could have done better and bring those up in the review. Write down everything you can that your reviewers bring up so that you can learn from the review.

also be ready to explain why you did certain things the way you did them.

DForck42
+4  A: 

The first thing I would suggest is to depersonalize the criticism of the code with criticism of you as a person. Your job does not define you as a person and your innate abilities to perform your job are not inborn and they can be learned. I think you also need to prepare less rather than more. View the review for what it is. It is an attempt to make your code higher quality. The meeting is intended to improve your skills and make you better in your craft. Preparing for any confrontational meeting can be mentaly taxing and discouraging. There is a principle which states "any defective organization will find n = 1 scapegoats to blame their problems on". Sometimes work environments are truly toxic. If that is the case I would prepare with a little reading of any good book which calms you down and makes you happy. Deal with the toxic environment outside of the code review.

ojblass
+1  A: 

I can see there's been quite some editing done to the question as originally formulated by hacklord :) Now this question makes somewhat more sense but is still far from programming-related. People getting rep for answering/asking this sort of questions... Let's make it a community-wiki, or delete it right away.

Oh, and my answer is, get a good night's sleep before you go into stressful situations like this. Might help you keep your cool and avoid getting more embarrassment from the code review :)

Peter Perháč
+6  A: 

Advice:

  • Acknowledge and paraphrase criticism (repeat it in your own words) to be sure you understand it and that your critics know they have been heard.
  • Politely insist that criticism be constructive: your critics must say how things should be done better.
  • Ask permission to record the session on your computer's mic. You can get a lot of voice at 8000Hz; that way you can focus on interacting with people and get the details later.
  • Schedule your day so that immediately after your review, you can leave the building and go for coffee for an hour. If you can, meet a trusted friend.

Thorough code reviews are never fun, but as you get more practice, the bleeding will stop quicker...

Norman Ramsey
+1000 for the scheduling tip
ojblass
A: 

I try to adopt these views:

  • Although the criticism may seem harsh, at least you have people who are investing time in looking at your code and there is a very good chance that you will view your code in a different light given that will have defend or explain your design decisions out loud. If I've spent too much time in my head with my code I don't know if it makes sense - it may work, but will someone be able to support it 9 months from now? Can they look at it and divine what my intent was?

  • When I go back to items I did last year, I realize that is was bad in many aspects. With a code review at least I know sooner and have a chance of correcting at least some of it.

Additionally I have found that if I keep it in mind that I will be going through a code review, I am more consistent with naming convention and coding style. Being embarrassed because I cobbled lines of crap together is enough to drive me to think "If I read this code on a blog, article or in a book, would I understand it, like it, and trust that it was written competently?" The humiliation of a bad code review is worth it because it will drive you to produce better code.

David Robbins
A: 

Part of preparing for a code review is writing better code. Knowing that someone is going to be looking over what you're working on and critiquing it helps drive you to writing better code. The "eh, but it works" excuse doesn't work on yourself as well when you know you're going to be reviewing this with your peers.

Use what you learn from one code review to write better code the next time. Strive to be better.

Jonathan