Slashdot Mirror


Are Code Reviews Worth It?

JamaicaBay writes "I'm a development manager, and the other day my boss and I got into an argument over whether it's worth doing code reviews. In my shop we've done both code reviews and design reviews. They are all programmer-led. What we've found is that code reviews take forever and tend to reveal less than good UI-level testing would. The payback on design reviews, meanwhile, is tremendous. Our code is intended for desktop, non-critical use, so I asked my boss to consider whether it was worth spending so much time on examining built code, given our experience not getting much out of it. I'm wondering whether the Slashdot crowd's experience has been similar."

345 comments

  1. Are they worth it? by Anonymous Coward · · Score: 1, Funny

    No.

    Discussion over, everyone go home.

    1. Re:Are they worth it? by Timothy+Brownawell · · Score: 4, Informative

      http://en.wikipedia.org/wiki/Code_review

      There are apparently a couple different kings of things that are both called "code reviews", which one are you talking about? There's also the issue that they're supposedly (as in, according to actual studies) pretty good, so maybe you could do them slightly differently and get much better (more in line with the study results) effects.

      More details on what your version of a "code review" and a "design review" are would probably get better answers...

    2. Re:Are they worth it? by Anonymous Coward · · Score: 3, Interesting

      I did a code review once at a previous job. It consisted of a bunch of people saying it looked good and one person giving wrong advice. I later found a bug in the code that everyone had missed. One person did comment afterwards that he learned a new trick reading my code.

      I think a code review at hire time, as part of the interview process, might be good... hell mandatory. I certainly wouldn't have hired the other developers in my group given the quality of code they produce (they were hired before me by someone who wasn't particularly competent himself)

    3. Re:Are they worth it? by Kjella · · Score: 4, Interesting

      There are apparently a couple different kings of things that are both called "code reviews", which one are you talking about? There's also the issue that they're supposedly (as in, according to actual studies) pretty good, so maybe you could do them slightly differently and get much better (more in line with the study results) effects.

      Formal reviews is only meaningful if you have an equally formal specification that is unlikely to change often or at all. A lot of heavy backend systems could benefit from that, but this isn't one of them they should definately stop. Of the lighter:

      Over-the-shoulder One developer looks over the author's shoulder as the latter walks through the code.
      Email pass-around Source code management system emails code to reviewers automatically after checkin is made.
      Pair Programming Two authors develop code together at the same workstation, such is common in Extreme Programming.
      Tool-assisted code review Authors and reviewers use specialized tools designed for peer code review.

      First one nearly never leads to good code in my experience, unless you manage to get just the right mix of writing code and helpful conversation, it's way too easy to zone out, take over, turn it into a lecture or whatever. Second one sounds like SPAM, who reads those? Pair programming can work, but I'm not sure it's worth the overhead.

      Tool assisted is definately my favorite. Clone and branch then make your changes and request that they be merged back. You have to say something sensible about what you're doing as a whole, at least two people will look at it, they can comment or reject it. Not according to guidelines or design or whatever? Fix and resubmit. That, together with design meetings I think is the way to go.

      --
      Live today, because you never know what tomorrow brings
    4. Re:Are they worth it? by Anonymous Coward · · Score: 0

      What does this have to do with "No"? You're answering the article, not the post you replied to.

    5. Re:Are they worth it? by man_of_mr_e · · Score: 5, Interesting

      Pair programming can work, but I'm not sure it's worth the overhead

      By "overhead" I assume you mean the cost of two developers to write one piece of code. In my experience, Pair programmers are more than twice as productive as a single developer when you factor in all the errors and bugs prevented by having two sets of eyes on the same problem. Of course this only works when you have a pair that can work together, which can be hard to find in some environments.

      The other advantage you get from pair programming is that you have two people familiar with the code, not just one. Thus if one leaves the company, or goes on vacation and problem needs to be fixed, you always have another person (at least until both of them leave the company).

      Even if you do nothing else that XP advocates, pair programming can really be worth it.

    6. Re:Are they worth it? by Glonoinha · · Score: 5, Insightful

      Pair programming is the most effective in the circumstance that makes the best use of it - two circumstances to be exact :

      1. Pair an experienced programmer with an inexperienced programmer.
      2. Pair an experienced programmer with strong subject matter expertise on one domain with an experienced programmer with a completely different domain of experience.

      The first is highly effective in getting the weaker guy up to speed on the first guy's domain. The second is effective at solving a set of problems that eclipse the domain of either developer.

      --
      Glonoinha the MebiByte Slayer
    7. Re:Are they worth it? by man_of_mr_e · · Score: 1

      I would have to wonder... how does the author know they don't get much out of code reviews? Is it just group think? Have they done a project without code review and compared defect rates? Have they done two post-mortem's and come to this conclusion?

      Maybe it's not the code reviews, but the way you're doing them? Maybe it's the personalities allowed to control the code reviews?

    8. Re:Are they worth it? by ivan256 · · Score: 4, Insightful

      In my experience, Pair programmers are more than twice as productive as a single developer when you factor in all the errors and bugs prevented by having two sets of eyes on the same problem.

      In my experience, pair programmers are only more efficient than each programmer working on their own when both programmers are bad.

      Bonus: Most development managers that like pair programming have hiring practices that find the worst programmers (but they're generally fairly well dressed and always show up to meetings on time).

      Good developers paired with over-the-shoulder code reviews produce code that is just as good (or better), and is far more productive.

    9. Re:Are they worth it? by DrLang21 · · Score: 2, Insightful

      Running good code reviews are like running any good meeting. It's difficult and often requires special skills that most people just don't have. Keeping people on track and on topic is difficult. Especially with us technical types.

      --
      I see the glass as full with a FoS of 2.
    10. Re:Are they worth it? by Anonymous Coward · · Score: 1, Interesting

      I agree. I kind of broke up the practice of pair-programming at my last job. Everyone on the team found that they were more productive if they were just let alone, had people to talk to if they had an actual problem, and just emailed each other their patches for "review". We would still pair for issues in multiple domains, but many times, a programmer and a chat client or the occasional "Hey, where does ... live?" is great.

      On the other hand, it's kind of nice to not have to type while you think.

    11. Re:Are they worth it? by Anonymous Coward · · Score: 0

      There are apparently...

      If you have no knowledge of the question at hand except what you've briefly read online, why do you feel justified in posting a response to the question?

    12. Re:Are they worth it? by halcyon1234 · · Score: 3, Insightful

      Pair programmers are more than twice as productive as a single developer when you factor in all the errors and bugs prevented by having two sets of eyes on the same problem.

      Also, having someone watch over you makes it harder to slack off on Slashdot. Harder, but not impossible, of course.

    13. Re:Are they worth it? by Anonymous Coward · · Score: 0

      are you done the .load() code yet????

    14. Re:Are they worth it? by imasu · · Score: 2, Insightful

      The first case is canonical and often pointed to, but I find it problematic in many cases. Mentoring is always a good goal but I think that for real development work, if there is a large disparity between the skillsets it can lead to the more experienced engineer becoming frustrated and essentially feeling less productive (as the mentoree is not contributing much in the way of actual implementation). Similarly, it can be like drinking from a fire hose or the less experienced person. So while it is an effective technique in some cases, it is (in my experience) quite domain and problem specific, and if the gap in skills is too large, it simply does not work well. The second example you give is where it really can stand out though, in the spirit of the first example as well; bringing a second experienced dev up to speed in the first dev's domain.

    15. Re:Are they worth it? by mr+exploiter · · Score: 2

      If my boss paired me with another programmer so he can learn from me then I'll expect him to pay me extra. No way I'm doing free teaching. I was hired for programming not mentoring. Stop trying to get free work from your employees.

    16. Re:Are they worth it? by wisty · · Score: 2, Insightful

      Pair programming is good for coding and software design (if you have a UI cases design), but crap for "UI, and model design by prototyping". If you want production code, you should use pair programming, design reviews, and code reviews. If you want to hack up a protoype (which you then refactor into a proper design, using pair programming, design reviews, and code reviews), then one person can be more creative than 2.

      Of course, some managers don't believe that development is a creative process, and think that they are the designers, but that's another problem.

    17. Re:Are they worth it? by wisty · · Score: 2, Interesting

      It also depends on the personalities. Some programmers are too egocentric to be useful in pair programming. They aren't too good in other contexts either though.

    18. Re:Are they worth it? by shentino · · Score: 2, Interesting

      Except that the company pays the opportunity cost of having you mentoring instead of coding, as you're on the clock either way.

      Unless of course he wants to have his cake and eat it to and have you programming and teaching simultanously.

    19. Re:Are they worth it? by complete+loony · · Score: 1

      I think the best question to answer when reviewing code is "Can I maintain this code if it needs to be modified?". Depending on the style of the developer you are reviewing, this could take seconds or hours to establish.

      --
      09F91102 no, 455FE104 nope, F190A1E8 uh-uh, 7A5F8A09 that's not it, C87294CE no. Ah! 452F6E403CDF10714E41DFAA257D313F.
    20. Re:Are they worth it? by Profane+MuthaFucka · · Score: 1

      One time my boss suggested I drive across town to meet with a guy for something I could have easily done in 5 minutes on the phone.

      I had no problem with that, as I make the same money if I am working hard, wanking in the toilet, or driving across town to ask someone if they're available for a meeting next tuesday. If my boss wants to pay me very well to do stupid things, that's not my problem.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    21. Re:Are they worth it? by Dahamma · · Score: 2, Interesting

      Good developers paired with over-the-shoulder code reviews produce code that is just as good (or better), and is far more productive.

      This I agree with wholeheartedly - a relatively quick over-the-shoulder review before a checkin provides the advantage of the extra eyeballs in pair programming/code reviews without the ridiculous disadvantages of redundancy and annoying meetings. Though as you said, it does assume good developers...

    22. Re:Are they worth it? by Mad+Merlin · · Score: 0

      Also, having someone watch over you makes it harder to slack off on Slashdot. Harder, but not impossible, of course.

      Are you trying to say that's a plus or a minus for productivity?

    23. Re:Are they worth it? by sodul · · Score: 2, Informative

      Google is using a code review tool called Mondrian. It was originally written by Guido van Rossum (Python's creator).
      He created an open source clone to be used with Subversion, Rietveld:

      http://google-code-updates.blogspot.com/2008/05/guido-van-rossum-releases-mondrian.html

      http://codereview.appspot.com/

      These tools are great but they are only as good as the guidelines for the reviews. Some reviewers will always say yes to requests, while others will be too anal. What happens? Most people will avoid strict reviewers and send their code to the easy ones. Doing a good review takes time so there need to be incentives to give good reviews: if you spend 2-3hs doing reviews in a day you just lost 25% productivity on your code, while helping an other developer write better code. Overall it's better for the team and the company but can actually hurt the perceived performance of your better developers while in fact they're pulling everyone else up. Just make sure good reviewers are getting as much recognition as good/productive code writers. Same thing goes with lenient reviewers, they should share the blame when bad code they reviewed brake the build. If you don't understand the new code, then it needs to be re-factored by the submitter to improve readability or you are not the right person to do the review.

    24. Re:Are they worth it? by uncqual · · Score: 1

      Huh?

      It completely depends on the impact of a software failure...

      Critical Space Shuttle software and Medical Radiotherapy software which can kill people and politically poison useful programs - yes.

      DBMS core which can corrupt data and/or return wrong results resulting in millions of dollars of cost to a customer - yes.

      A GUI component which at worst will leave a few pixels of GUI Poo on an in-house application or require backing down to the prior release - not so much (well, probably not at all).

      --
      Why is there an "insightful" mod and why isn't it "-1"? If I wanted insight, I wouldn't be reading /.
    25. Re:Are they worth it? by localtoast · · Score: 1

      That movie Tommy Boy comes to mind. The quote was something like this: I can take a dump in a box and mark it guaranteed. All that I've done is sold you a guaranteed piece of shit.

    26. Re:Are they worth it? by man_of_mr_e · · Score: 3, Interesting

      Good developers paired with over-the-shoulder code reviews produce code that is just as good (or better), and is far more productive

      My experience differs. Most people that say they're "good developers" aren't. What you really mean is "People that hate having someone watch them don't do well in pairs", and that's true.

    27. Re:Are they worth it? by dna_(c)(tm)(r) · · Score: 1

      In my experience, Pair programmers are more than twice as productive as a single developer when you factor in all the errors and bugs prevented by having two sets of eyes on the same problem.

      This is a bovine manure argument. "I hate pair programming therefore programmers who like it are stupid".

      Pair programming is not only about making fewer mistakes, it helps communication, spreading knowledge about code and best practices and it helps keeping disciplined about unit tests etc.

    28. Re:Are they worth it? by man_of_mr_e · · Score: 3, Insightful

      Everyone on the team found that they were more productive if they were just let alone, had people to talk to if they had an actual problem, and just emailed each other their patches for "review".

      I've had numerous 4-6 hour pair programming sessions that churned out more well written, largely bug-free software than most people write in a week.

      The problem is, when pairs are mandated, you end up with a situation where you write code for 5 minutes, then one guy gets up to go to the bathroom for 15 minutes (the other guy surfs the web waiting for him to get back). Then they write more code for 5 minutes and the other guy goes to get a can of Dew, stops and chats with someone, etc.. comes back and they write 5 minutes of code and then the first guy goes to lunch... etc..

      You need two people that are a team, working together, who want to be there and doing it. Otherwise it's just pointless. In most cases, I like to find an unused conference room or office to allow us to be completely "in the zone", and we generally don't come out until we're done for the day.

      Occasionally you get into a disagreement about how to go about things, and that wastes time. But more often than not, a pair that's "in sync" churn out amazing amounts of good code.

      The fact that you talk about mailing each other patches seems to indicate to me that you're talking about a maintenance situation. Pair programming does not work well for small patch change situations, or rather it's a waste of time.

    29. Re:Are they worth it? by johannesg · · Score: 1

      No.

      Discussion over, everyone go home.

      And people wonder why geeks are reputed to have bad communication skills.

      If you are also suffering from such a reputation, here's an idea on how to improve things: when someone asks a serious question don't just say "no" without stating any reasons or even looking up from your keyboard. Instead, look up from your keyboard (*and* stop typing!), look thoughtfully to the person asking the question, and begin with "that's a pretty interesting question. But in my opinion, that's not the case, because ..." And then you provide a list of reasons.

      Sure, you waste time when talking to "idiots" like this. But you will find that people will like you a lot more, and start to accept you as a human being as well. And who knows, maybe one day it will lead to an encounter with the opposite sex.

      See? You really *can* learn useful things on slashdot!

    30. Re:Are they worth it? by uncqual · · Score: 1

      Who is accountable? The CODER and the FORMAL REVIEWER!

      It's fine to "reduce risk" by "over the shoulder" reviews, but, in the end, no one is accountable and no one has a clue if the software is of adequate quality unless there is more formal tracking, resource allocation, and accountability. As a software development manager, I figure that reviewing code properly typically requires 20%+ of the resources to write the code (the 20% is assuming a domain expert reviewer). The reviewer is as responsible for the correctness (not the style of code or algorithms) as the coder is!

      --
      Why is there an "insightful" mod and why isn't it "-1"? If I wanted insight, I wouldn't be reading /.
    31. Re:Are they worth it? by Hognoxious · · Score: 4, Funny

      In my experience, Pair programmers are more than twice as productive as a single developer when you factor in all the errors and bugs prevented by having two sets of eyes on the same problem.

      In my experience, unicorns are 2.7 times better than mermaids at debugging.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    32. Re:Are they worth it? by kenp2002 · · Score: 1

      Pair programming is the most effective in the circumstance that makes the best use of it - two circumstances to be exact : 1. Pair an experienced programmer with an inexperienced programmer.

      Why the hell would anyone in their right mind in business pursue #1? I have no idea what company you work for but normally compaines don't hire inexperienced programmers. Why would I waste money on somone who isn't experienced? The whole point of interviews, resumes, and searching for canidates is to get the best, qualified person for the dollar amount. I get a project specification on Jan 3rd and it needs to be in production in 13 weeks. I don't go out and hire inexperienced programmers for 13 weeks. Not 1. 13 weeks gives me at most 6 builds for integration testing and another 4 for user acceptance and business line testing. Where ever you work, enjoy it, the rest of us don't have the luxury of having someone with experience wasting time mentoring on the company and project's dime. You suggestion of #2 is far more acceptable but #1? We fire poor performers, we do not waste time and money on them. This may work in public education and the public sector but businesses can't afford bad staff.

      --
      -=[ Who Is John Galt? ]=-
    33. Re:Are they worth it? by ahabswhale · · Score: 1

      Mentoring is NOT pair programming. Pair programming only happens when both developers are roughly equal in skill level. This is not to say mentoring is bad but I get tired of people confusing the two ideas as they are completely different concepts. I think you need to read up on what pair programming is actually about.

      --
      Are agnostics skeptical of unicorns too?
    34. Re:Are they worth it? by Your.Master · · Score: 2, Insightful

      have no idea what company you work for but normally compaines don't hire inexperienced programmers.

      Where do you think experienced programmers come from?

      Yeah, yeah, cue the litany of Open Source projects. There's more than one kind of inexperienced, and Open Source doesn't prepare you for all aspects of business programming (nor vice-versa).

      Lots of companies have internships, hire kids out of school, hire experts in one domain to help bring their skills into another domain, etc..

      Also, near the end:

      We fire poor performers, we do not waste time and money on them.

      He said inexperienced programmers, not poor performers. There's an enormous difference. The concepts are almost orthogonal.

      I get a project specification on Jan 3rd and it needs to be in production in 13 weeks. I don't go out and hire inexperienced programmers for 13 weeks.

      So you do contract work only? Nobody is suggesting you do charity work on these cases. But it kind of answers your beginning question: "Why the hell would anyone in their right mind in business pursue #1"? Because they hire for a much longer term than 13 weeks. 13-week terms: that actually sounds like an educational stint.

    35. Re:Are they worth it? by Ihlosi · · Score: 1

      Why the hell would anyone in their right mind in business pursue #1? I have no idea what company you work for but normally compaines don't hire inexperienced programmers. Why would I waste money on somone who isn't experienced?

      1. Experienced programmers are expensive.

      2. The task at hand may not require an experienced programmer.

      3. Once the inexperienced programmer gains experience, he may be less expensive than hiring an experienced programmer in the first place (if he's a sucker and sticks around. Remember that the larged salary increases usually happen by switching jobs).

    36. Re:Are they worth it? by MadKeithV · · Score: 1

      There's nothing stupid about teaching more junior developers about good practices.

    37. Re:Are they worth it? by Profane+MuthaFucka · · Score: 2

      I agree. But...

      Mr. Exploiter obviously thinks the practice is stupid. Now,

      a) try to convince him that it's not stupid
      or
      b) explain that he makes the same money for jerking off as he does for programming

      I think I took the easier path.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    38. Re:Are they worth it? by ivan256 · · Score: 1

      You don't judge whether somebody is good or not based on whether they say so.

      Everybody says they're good. Especially at a job interview.

    39. Re:Are they worth it? by kenp2002 · · Score: 1

      No contract work. Quarterly release schedules. Roughly 13 weeks from development to production.

      --
      -=[ Who Is John Galt? ]=-
    40. Re:Are they worth it? by kenp2002 · · Score: 1

      Why the hell would anyone in their right mind in business pursue #1? I have no idea what company you work for but normally compaines don't hire inexperienced programmers. Why would I waste money on somone who isn't experienced?

      1. Experienced programmers are expensive.

      2. The task at hand may not require an experienced programmer.

      3. Once the inexperienced programmer gains experience, he may be less expensive than hiring an experienced programmer in the first place (if he's a sucker and sticks around. Remember that the larged salary increases usually happen by switching jobs).

      1: So is failure.
      2: Then it is cheaper to outsource the task to an external vendor.
      3: With programming costs these days that investment in US labor rarely has a return on it. With 3% inflation and only 5% productivity improvements per year on average I'm only coming out head 2% on my labor. That is a pretty crappy return on investment in labor. Add in health care and annual 3-5% raises I lose. A lot. There is no incentive. Even if a can clear someone at 10% under market rate they're a liability after 3 years. I'd have to get someone at least 50% off market rate to make it even worth considering and the costs involved with missing deadlines... an inexperienced programmer would never clear the risk analysts.

      --
      -=[ Who Is John Galt? ]=-
    41. Re:Are they worth it? by hrimhari · · Score: 1

      I'm so happy that not every company is like yours! I'd love to watch you find experienced programmers otherwise.

      --
      http://dilbert.com/2010-12-13
    42. Re:Are they worth it? by XMyth · · Score: 1

      That's twice you've mentioned being paid for masturbating.

      Just an observation.

    43. Re:Are they worth it? by Profane+MuthaFucka · · Score: 2

      I telecommute from home, so yes I rub one out on the clock every day. I'm sticking it to the Man. So to speak.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    44. Re:Are they worth it? by arieswind · · Score: 1

      You sound like a absolutely terrible person to work for.

      1. Hiring a fresh grad for 40-50k (especially one who is quick to learn) over someone with 10 years of experience for 80-90k+ will often come out ahead for those positions that do not absolutely need that 10 years. Even if it takes them a few months to get the hang of what youre doing, if they end up 75% as productive as your senior coders, you come out way ahead

      2. I would take a less experienced programmer on my payroll over an outside vendor any day of the week for non-complicated tasks, and twice on monday. Anyone whos had to deal with a bad vendor will agree.

      3. A new programmer will grow and learn far faster than an experienced one(especially if it is their first real job.) a new programmer could be 2 or 3 times as productive 6 months in as they were at 1 month in

      Of course, since youve reduced all your employees to a number, things like these probably never cross your mind.

      (PS. if all your inexperienced people miss every deadline, youre picking the wrong hires. Not only that, but dont ever assume that experience = no mistakes or failures. Or maybe the environment youve created is that detrimental to work flow.. Hiring someone with every expectation of their failure never did anyone any good)

    45. Re:Are they worth it? by Anonymous Coward · · Score: 0

      With 3% inflation and only 5% productivity improvements per year on average I'm only coming out head 2% on my labor. That is a pretty crappy return on investment in labor. Add in health care and annual 3-5% raises I lose. A lot. There is no incentive. Even if a can clear someone at 10% under market rate they're a liability after 3 years.

      That makes no sense. Health care and raises are factored into inflation... why did you factor inflation in twice? If your labor productivity is going up 5% a year and cost inflation is 3%, that means you are earning an extra 2% on your margins every year -- you are making more and more money without having to hire additional resources, expand the business, etc.

      Do you talk out of your ass all the time, or is mostly just today?

    46. Re:Are they worth it? by kenp2002 · · Score: 1

      1: I would never hire a graduate at 40k. Are you daft? If he's a Harvary\Berkley\Princeton graduate maybe. And that is a big maybe. These are programmers not mechanical engineers. Code jockeys! Software engineers spend their time on UML documents not code. You over pay for your programmers. Starting, tops, 25k a year. It's a global economy and american labor is over-paid. At 80k through promotions and years of service I get, "Someone who actually answers their pager in emergencies", shows up to work on time and leaves on time, can work with the other 1200 other project participants; and can wash their hair and keep the number of extra holes in their head to a minimum so when you are sitting down with clients wanting to sign a 20 million dollar, 8 year contract, your senior programmer doesn't look like a homeless beatnik or reject from a stage production of Dracula.

      I have two guys in Moscow that clear 75k and they can actually get to a meeting at 3AM for architecture reviews with 2 in Italy, 1 in Hong Kong, and 12 coders in Seattle. (I'm in Central time). I can't even get this crap they graduate out of bed to attend a meeting, hell I'd be happy if the crap they hand me could get to work before 10 AM. Not everyone is a Silicon Valley genius, Most a mediocre at best.

      2: You need vendor risk assesment in place. Risk mitigation allows the vendor to bear the expense of a missed deadline, not my budget. If it is a low skill task farm it out and let the high skilled people focus on core objectives that can't be delegated. First Rule: Screen your vendors. Make sure you do vendor credit reviews.

      3: Are you implying people with experience are stupid? I've seen 20 year Cobol programmers go to Java bootcamp and come back better then that excrement the U of M puts out after 4 years. Experienced programmers learn new skills far better because they can apply their experience in the real world to the learning process without getting distracted by frat nonsense and teachers who are too busy trying to get their students to vote for X,Y, and Z. A new programmer learns quicker? Nonsense. Your implying that older programmers learn slower.

      The capacity to learn is a quality of the individual and how they apply their education and life experiences. I've dealt with that nonsense in the late 90s. I have zero faith in public education (I don't hire public educated people. Ever. You'd be amazed how that fixes a lot of problems.) and even less year after year in US education. Eastern Europe is where the hot talent is developing these days.

      As far as the PS part, you miss a deadline, there is no "another time". You don't miss deadlines, that's why their called deadlines. If meeting them were optional they'd be more of suggestions then deadlines. You miss a deadline, you are transfered to the unemployment department.

      But all that aside I am now a soft cuddly retired geek spending his days as a nobody in a cube helping out some friends. But at least I can look back at my tech days and say, "Never over budget. Never missed a deadline. And shit worked the first time."

      I don't assume experience means less mistakes, just quicker to find the mistake and quicker to fix it.

      Don't get me wrong, what you say sounds nice but sure as hell in the years I worked my employers over the years have no tolerance for failure unlike the public sector where failure is the norm.

      And I am easy to work with, not easy to get hired by. I tend to hire former Military (Hard to go wrong there as long as they pass the psychologist's twice-over) and those who have a solid portfolio of work. I'm even kind enough if a canidate catches my eye to let him\her complete a few sample programs before I made a decision to give them the chance (and have a portfolio in the future. My favorite is to sort an arbitrary sized text file with variable number of threads)

      I just have a zero bullshit tolerance anymore. No employer has ever paid me to be nice that's for sure. But my coworkers and peers like me at least. I do think the wife just tolerates me though at times.... Whatever...

      Ehh I'm tired but that's my 2 cents. The world I live in is a lot harder then yours it appears.

      --
      -=[ Who Is John Galt? ]=-
    47. Re:Are they worth it? by SirGeek · · Score: 1

      More details on what your version of a "code review" and a "design review" are would probably get better answers...

      It also matters about the purpose. Are you trying to ensure the code actually implements the design (there IS a design, right ?) or are you trying to verify that the design meets the requirements (you have requirements, right ?) ....

    48. Re:Are they worth it? by Max+Littlemore · · Score: 1

      In my experience, pair programmers are only more efficient than each programmer working on their own when both programmers are bad.

      That's a bit of a generalisation. I used to work in a small shop, primarily with one other developer plus the UI design and management bods. This dev and I used to work alone a lot, but on occasion we would pair up, particulary when we were starting something new. The rate that we turned out code was staggering compared to dividing the work and going it alone. Also, the code was usually highly optimized and error free. I put it down to having not only the two sets of eyes, but also the brains of two highly experienced engineers each thinking about two or three different aspects of what a given piece of code is trying to do.

      This situation is also a lot of fun if you do it with someone you can work and communicate well with. You basically have a conversation about everything you are trying to do and watch the code morph into a simple, elegant and powerful solution in a time frame that even the most amazing code guru could not achieve. That is an absolute hoot if you appreciate good code more than ego maintenance.

      Which brings me to my point. Perhaps the fact that you think that pair programming is only good for bad programmers is that you are a one of those developers that likes to be right, will argue a position where this is no right answer as if everything is absolute and tends to choose obscure solutions just to appear smart and perhaps ensure job security. The industry is full of those.

      They make aweful pair programmers and aweful programmers in general, IMO. Being stuck with maintaining the code of a solo genious sucks big time, not because I find it hard to understand what they have done, but more because I have trouble understanding why they have done it the way they have. Pair programmed code is by it's nature easier to understand and thus maintain because it benefits from the perspective of two authors.

      Maintenance and patching are of course a waste of time in pairs, but for new code it is excellent.

      --
      I don't therefore I'm not.
    49. Re:Are they worth it? by ivan256 · · Score: 1

      This situation is also a lot of fun if you do it with someone you can work and communicate well with. You basically have a conversation about everything you are trying to do and watch the code morph into a simple, elegant and powerful solution in a time frame that even the most amazing code guru could not achieve. That is an absolute hoot if you appreciate good code more than ego maintenance.

      I won't disagree with this. Having fun and writing code in a social manner does not necessarily translate into greater productivity though.

      Which brings me to my point. Perhaps the fact that you think that pair programming is only good for bad programmers is that you are a one of those developers that likes to be right, will argue a position where this is no right answer as if everything is absolute and tends to choose obscure solutions just to appear smart and perhaps ensure job security. The industry is full of those.

      Actually, that's exactly the type of programmer that I think benefits the most from pair programming. They'd benefit more from being fired though.

    50. Re:Are they worth it? by SharpFang · · Score: 1

      Depends on the people and organization.
      The younger one gets to more mundane tasks - writing debug code, writing easy, simple, mundane pieces - the UI, the testcases. The more experienced one concentrates on more tricky code, then gets the young one to check his code, explaining it line by line. They work together on the hardest pieces.

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
  2. Synergy, leverage, low hanging fruit, etc.. by Anrego · · Score: 5, Informative

    Having worked on life critical type systems where every line of code was reviewed before making it into the product, I have to say that I've seen them add a lot of value when done properly.

    They also cost a lot.

    The first question I would ask in your situation is: are you doing them right?

    Do bugs get discovered later after deployment? Are the bugs in areas of the code that were supposedly reviewed? If so, you might be doing it wrong.

    And as much as we _hate_ the word... I have to say it...

    METRICS!

    If you truly want to make a decision on whether code reviews are worth it.. you need to know:
    - how much does it cost to conduct the reviews
    - how many defects are discovered in the review versus how many make it out the door (in other words, how good are you at it)
    - how how much more does it cost you when a bug gets discovered after deployment? In a life critical system, it costs a fucktonne.. in a desktop app.. it may not be that bad.

    Once you know these, the picture should be clear

    1. Re:Synergy, leverage, low hanging fruit, etc.. by Tx · · Score: 4, Funny

      If you truly want to make a decision on whether code reviews are worth it.. you need to know[...]

      So what you're saying is we have to have a review of the reviews...we're going to be here a while aren't we?

      --
      Oh no... it's the future.
    2. Re:Synergy, leverage, low hanging fruit, etc.. by Anrego · · Score: 2, Insightful

      Oh calm down..

      it's a pretty easy thing to track.. most shops already have a bug tracking system.. you just need to add in a way to track how much stuff gets discovered in code reviews.. then have some intern hack out a spreadsheet in leu of getting valuable job experience.

    3. Re:Synergy, leverage, low hanging fruit, etc.. by Skuld-Chan · · Score: 2, Informative

      Sadly every security vulnerability on the products I've worked on were found after shipping in code that was reviewed (and not only that - sometimes very obvious bugs - like treating strings as fixed values, and not checking or sanitizing inputs).

      So I guess they either have to be done right, or they aren't all that useful.

    4. Re:Synergy, leverage, low hanging fruit, etc.. by piojo · · Score: 4, Interesting

      how many defects are discovered in the review versus how many make it out the door?

      I don't think defects are the only metric. Code reviews can result in a cleaner codebase that's easier to understand. Everyone occasionally writes bad code. A reviewer might say, "I see that it works, but I don't like it..." and mention an alternative solution. A reviewer might suggest that something is non-obvious and that a comment is warranted. Code reviews aren't just for bugs, they are to get better code.

      --
      A cat can't teach a dog to bark.
    5. Re:Synergy, leverage, low hanging fruit, etc.. by K.+S.+Kyosuke · · Score: 1

      You are not funny with those reviews of reviews! *sigh* Now I will have to metamoderate your Funny moderation down.

      --
      Ezekiel 23:20
    6. Re:Synergy, leverage, low hanging fruit, etc.. by Bill,+Shooter+of+Bul · · Score: 4, Insightful

      Exactly. Its also a great way to mentor newer developers and teach them the tricks of the trade. There is always more than one way to do something, but often they vary greatly in their performance and readability.

      --
      Well.. maybe. Or Maybe not. But Definitely not sort of.
    7. Re:Synergy, leverage, low hanging fruit, etc.. by MrMista_B · · Score: 2, Funny

      Well, in that case, we should do a thorougly review of the reviews of the reviewed review reviews.

      BUFFER OVERRIDE

    8. Re:Synergy, leverage, low hanging fruit, etc.. by Tawnos · · Score: 1

      Is that like a buffer overflow?

    9. Re:Synergy, leverage, low hanging fruit, etc.. by DrLang21 · · Score: 1

      I think this needs to be done with great care. Suggestions can always be made, but if you halt progress to fix some code that works reliably for the sake of cleanliness, you can quickly get bogged down in word-smithing that adds little value. Findings in code reviews need to be prioritized. If it works but is written a bit ugly, make a note of it. If it works but has unacceptable holes in it, put it on a moderate priority. If it does not do what is intended at all, put it at the top of the list. And so on.

      --
      I see the glass as full with a FoS of 2.
    10. Re:Synergy, leverage, low hanging fruit, etc.. by Braino420 · · Score: 1

      Its also a great way to mentor newer developers and teach them the tricks of the trade.

      Agreed. I'm a junior dev, and I have learned a few things from our group's team lead during code reviews. It also helps in the communication between the devs and the team lead. For instance, if some library code we're using needs refactoring because it's making our code awkward, it's helps him identify if we should possibly spend some time working on that to help the whole team write better code.

      --
      They call me the wookie man, I guess that's what I am
    11. Re:Synergy, leverage, low hanging fruit, etc.. by cheftw · · Score: 1

      It was, until he overrid the buffer that contained it.

      --
      Always back up, never back down. ---- Think you're cool 'cos your uid is prime? Take mine, modulo the one digit integers
    12. Re:Synergy, leverage, low hanging fruit, etc.. by Anonymous Coward · · Score: 0

      And as much as we _hate_ the word... I have to say it...

      METRICS!

      Here in the U.S. we still use the "Imperial" system- The person with the most power makes the decision.

    13. Re:Synergy, leverage, low hanging fruit, etc.. by ChartBoy · · Score: 1

      More like a buffer overload

    14. Re:Synergy, leverage, low hanging fruit, etc.. by Anonymous Coward · · Score: 1, Interesting

      I can say in our company the benefits are multi-fold.

      Programmers skill levels vary. And also vary by subject. If you are going to allow someone to code the multi-threaded part of your project how do you insure that they've protected the write code the write way - which thread synchronization element did they use where? Also remember the uproar about the code SGI put into Linux that SCO was bantering about. I believe it was simple memory allocation. Stuff that already existed elsewhere - duplicated uselessly. Does everyone on your team know how to optimize C++ STL?

      Then there is maintainability. Lets forget outsourcing for a moment. I'm currently rewriting a large chunk of code - written in C#. If you think Java had a tough time in the early years because of junk 'web' programmers, you haven't seen anything yet. Everyone and their mother thinks they can code in C#. In my case the implications of using events, poor locking strategy etc. gave me the opportunity of 7x performance increase. Yes, 700%. Apparently waiting for the GUI to update isn't good for a background thread. They did things like send data across a network, start a thread to wait for response, then send an event to tell another thread that data had arrived. From a design review I'm sure it looked OK. "Hey we are doing asynch communication!!!!"

      I know I hate it, but what about variable names. Who checks if the comments make sense?

      As the developers get better code reviews become less fruitful. One of the issues I have now is that most sleep through the code review. I don't mean literally, but I showed my code, everyone agreed it was good, only to have me go back to my desk and realize it would crash on one of the exception cases. Hopefully testing would have caught it - we'll never know.

      So... what we do for code review is a 1 on 1 session. It is the developers job to convince the mentor that he, the developer, is doing the job right. It is then the mentor who makes the final submission (he buys the donuts if the build breaks :) ) The idea is to keep from rubber stamping.

      So defect catching is one part. Performance another, and maintainability yet another.

      BTW, before my changes to the code, everyone thought our competitors product was better/faster. Now we are about 20-30% ahead of them. So what did that cost our customer base?

      Of course now everyone in the company thinks I'm god (my head barely gets through the door as it is). If only we did this code review before we shipped.

    15. Re:Synergy, leverage, low hanging fruit, etc.. by cetialphav · · Score: 2, Insightful

      you need to know:
      - how much does it cost to conduct the reviews
      - how many defects are discovered in the review versus how many make it out the door (in other words, how good are you at it)
      - how how much more does it cost you when a bug gets discovered after deployment?

      The great thing is that none of these metrics are that hard to collect. You should already know the cost of production bugs because that is just a basic component of your business.

      To collect the cost to conduct reviews, you just need to ask everyone who does a review how long it took them. You can store this on paper or in a simple little database. Reviewers just need to remember to look at the clock when they do the review. Some computerized review systems can collect this for you automatically.

      To track the defects, you just need to track when someone says "You need to change this because ...". Assigning someone as a secretary in a meeting works well (assuming you have a meeting). Or you can just collect this in the emails or other online system that you use. The harder thing is to estimate the value of these found defects, but it isn't too hard to come up with some simple heuristics that serve as a reasonable approximation.

      Clearly, many organizations collect this in a way that is painful and intrusive and that gives these metrics a bad name. But it doesn't have to be that way. I have seen this done in simple ways that flow easily with the rest of the development process. Having this information is extremely powerful because without it everyone is just guessing and you become subject to the hunches of middle management because their guesses have more weight since they are the boss.

    16. Re:Synergy, leverage, low hanging fruit, etc.. by flydpnkrtn · · Score: 1

      Better than an acid burn, not as tasty as a crash override!

    17. Re:Synergy, leverage, low hanging fruit, etc.. by Anonymous Coward · · Score: 0

      Nah, the fact is that reviews of code take time, and they can be fixed after your former clients find the holes.

    18. Re:Synergy, leverage, low hanging fruit, etc.. by martin-boundary · · Score: 1

      Excuse me, is a review of a review an unknown unknown? I've just started subscribing to Dr Rumsfeld's newsletter, and I'd like to apply what I've learned so far.

    19. Re:Synergy, leverage, low hanging fruit, etc.. by ClosedSource · · Score: 1

      I agree. There's some definite value in paying for the future in the future. That's particularly true when the future you expect may never occur (e.g. that section of code never gets touched again).

    20. Re:Synergy, leverage, low hanging fruit, etc.. by hplus · · Score: 3, Funny

      Wait, so you are reviewing somebody else's review of the comment talking about reviewing reviews?

    21. Re:Synergy, leverage, low hanging fruit, etc.. by Unoti · · Score: 5, Insightful

      So what you're saying is we have to have a review of the reviews...

      Actually, it's reasonable to periodically review and improve and streamline all of your processes. Any part of the process that takes time or money should be justified by an improvement in the metrics after adding that part of the process. if the metrics don't improve after adding that part, then that part should be removed from the process. This can help lead to less busywork and less paperwork, rather than more, as it sounds at first blush.

    22. Re:Synergy, leverage, low hanging fruit, etc.. by DMeans · · Score: 2, Insightful

      I work for a very large software company, on a mission critical module used by very many companies. - How much do reviews cost? We don't care. - How many defects are found? Sometimes none. - How much does it cost when a bug exists? What you said. Code reviews are mission critical to my team. Software doesn't ship without them. Sometimes the code review finds the bug, sometimes it doesn't. But in the end, we have the check-box marked and it saves our bacon.

    23. Re:Synergy, leverage, low hanging fruit, etc.. by shentino · · Score: 1

      Sad but true.

      How I wish I could moderate and THEN post...without losing my mod points or getting my moderations undone.

    24. Re:Synergy, leverage, low hanging fruit, etc.. by piojo · · Score: 1

      ...if you halt progress to fix some code that works reliably for the sake of cleanliness, you can quickly get bogged down in word-smithing that adds little value.

      I agree--this happened to me, in fact, when I wrote a minor feature for an open source project. Several times there was always a reply to my patch saying, "you should fix this", or "yeah, but it would be nice if you did this, too..." It was kind of disheartening... but I still like code reviews, in general.

      --
      A cat can't teach a dog to bark.
    25. Re:Synergy, leverage, low hanging fruit, etc.. by Anonymous Coward · · Score: 0

      The most important thing I have found is that knowing your code is going to be thoroughly reviewed causes you to write better code in the first place.

    26. Re:Synergy, leverage, low hanging fruit, etc.. by Carewolf · · Score: 2, Insightful

      Well, code reviews are boring to do, but has to be done be the best and most experienced developers usually the senior or lead developer. Some places doesn't understand that and just delegates this menial task to lower developers, or a team of inexperienced developers. Other places the top developer assigned the task, just skips through the code, because he thinks he has "better things to do".

    27. Re:Synergy, leverage, low hanging fruit, etc.. by Anonymous Coward · · Score: 0

      Parent is correct. METRICS on your review processes is key. Spend at least a few months carefully gathering data. Also, it is possible that you aren't motivating the reviewers properly, so the reviews aren't doing all they should?

      Key questions for any review process:
      - What is the most efficient number of reviewers? 2 experts is generally the best answer for software
      - At what stage of the delivery process are bugs found? Usually, earlier is cheaper to correct than later.
      - Does your process properly measure "what you really want?" Be careful what you measure, because that is what you'll get.

      I've worked in CMM-5 development and no process environments and somewhere in between.

      In CMM-5 environments, you "knew" your code was extremely high quality and our multi-level testing teams were extremely frustrated. The team of 22 developers introduced 1 bug every 2 years. This was on the space shuttle GN&C flight software. Very meaningful work with lives and expensive vehicles on the line.

      For the other two environments, 1 team had zero process but each of the 9 developers was extremely skilled and conscientious. Any bug was considered a very personal thing and corrected immediately. Memory leaks were considered MAJOR bugs and corrected immediately. No reviews were performed after a design white board presentation. This was cross platform code used in every NASA mission control center and partner control centers world wide. We didn't track any bug/issue statistics, but my feeling was we didn't need to. The software was extremely high quality. Very meaningful work with lives and expensive vehicles on the line.

      The last place had normal skill level developers that used no process when I arrived. They were under so much pressure to add functions that bugs were introduced constantly. I introduced daily builds and build testing. We brought in QA and bug tracking software, which we needed very much. With only 7 developers, we had thousands of bugs. Most of the bugs were in the GUI, with just a few on the server side. There was little support from management for any process at all. We started doing extreme programming and added project management to manage all the changes. We hired more developers and more and stole people from other teams. The software got buggier and buggier the more average programmers that we added. In the end, 3 of the 15+ programmers were highly skilled guys. They could work on pacemakers or airplane code. The rest were just trying to get paid and laid. Then the company was bought out and I left. Not meaningful work. Nobody cared whether the code worked or not except the customers. Almost no motivation beside pay to do it right.

      In each of the environments above, when the code had to be high quality because lives were on the line, that's what we got.

    28. Re:Synergy, leverage, low hanging fruit, etc.. by Cola+Junkee · · Score: 1

      That sounds complicated.

      Are you really sure you want to jump into that without a review first?

      --

      f u cn rd ths, u r prbbly a lsy spllr.

    29. Re:Synergy, leverage, low hanging fruit, etc.. by Coz · · Score: 1

      Amen.

      One of the things that the metrics can hide, though, is the effect of institutionalizing reviews. If you're on a long project with the same team, everyone begins to perform to a certain level and the code reviews seem to lose their importance. It's ironic, it is.

      If you have new folks join the team, though, it usually only takes a few code reviews for them to "get it" and figure out the level of expertise expected.

      On my favorite project so far, we had full code reviews for the first phase, and dialed them back to "peer reviews" requiring only 2-3 folks to do online review of the code units. Critical units were also reviewed by the lead developer and systems engineer responsible for that component. It was very much worth it.

      --
      I love vegetarians - some of my favorite foods are vegetarians.
    30. Re:Synergy, leverage, low hanging fruit, etc.. by gnasher719 · · Score: 1

      I don't think defects are the only metric. Code reviews can result in a cleaner codebase that's easier to understand. Everyone occasionally writes bad code. A reviewer might say, "I see that it works, but I don't like it..." and mention an alternative solution. A reviewer might suggest that something is non-obvious and that a comment is warranted. Code reviews aren't just for bugs, they are to get better code.

      Another important aspect is that code that is going to be reviewed will be better in the first place than code that isn't going to be reviewed. So it is quite possible that no bugs or code ugliness will be found in the code review, because the developer worked more carefully and removed the bugs _before_ the code review.

    31. Re:Synergy, leverage, low hanging fruit, etc.. by myrikhan · · Score: 1

      Well, in that case, we should do a thorougly review of the reviews of the reviewed review reviews.

      BUFFER OVERRIDE

      Wait! Lets not jump into things. First we need a pre-review meeting where we consult all the stakeholders and proactively leverage our synergies to create a win - win scenario for the customer...

    32. Re:Synergy, leverage, low hanging fruit, etc.. by Anonymous Coward · · Score: 0

      Besides mentoring its also a good way of ensuring individuals in the team understand the code/design and what went in why. Team members tend to split work out and become experts in a narrow subset of code. Code reviews is a great way of spreading the knowledge around.

    33. Re:Synergy, leverage, low hanging fruit, etc.. by Anonymous Coward · · Score: 0

      I think you meant BUFFER OVERFLOW...but this would more accurately be a STACK OVERFLOW as it is an infinite recursion.

    34. Re:Synergy, leverage, low hanging fruit, etc.. by Mr.+Slippery · · Score: 1

      code reviews are boring to do, but has to be done be the best and most experienced developers usually the senior or lead developer. Some places doesn't understand that and just delegates this menial task to lower developers, or a team of inexperienced developers.

      While it's necessary to have senior developers take part in the review, having only senior developers do it misses part of the benefit -- code reviews should be educational. They should allow newer developers to learn from the good coding habits of more senior people, and also to see mistakes and thus learn to avoid them.

      If you want to learn to be a writer, you have to read. That applies to code as much as it does to books or poems or essays.

      --
      Tom Swiss | the infamous tms | my blog
      You cannot wash away blood with blood
    35. Re:Synergy, leverage, low hanging fruit, etc.. by DigitalCrackPipe · · Score: 1

      I agree - my first thought was that the reviews are being done wrong - perhaps focusing on the wrong things, inviting the wrong people, or just plain not having someone in charge to keep things flowing.

      My next thought is that the results of design reviews are going to be viewed differently - changing the color of a button is likely to be more noticable than fixing a buffer overflow that is only exhibited if the right data is input.

      My personal experience is that code reviews are invaluable when done right. However, a huge number of people don't understand them at all and try to do them wrong.

    36. Re:Synergy, leverage, low hanging fruit, etc.. by Anonymous Coward · · Score: 0

      Sadly every security vulnerability on the products I've worked on were found after shipping in code that was reviewed (and not only that - sometimes very obvious bugs - like treating strings as fixed values, and not checking or sanitizing inputs).

      So I guess they either have to be done right, or they aren't all that useful.

      These kinds of bugs should be caught in testing, even if your code review missed it. Depending on your way of developing code for delivery, test can sometimes be cheaper than code reviews. Maybe you need to make your testing process a little more rigorous ($$$).
      Herb

    37. Re:Synergy, leverage, low hanging fruit, etc.. by Hurricane78 · · Score: 1

      In a life critical system, it costs a fucktonne..

      That's a "nice" way, of saying, that a human being just died for no reason at all, but you screwing up. :/

      How many fucktonnes did the Iraq war cost btw?

      --
      Any sufficiently advanced intelligence is indistinguishable from stupidity.
    38. Re:Synergy, leverage, low hanging fruit, etc.. by Hurricane78 · · Score: 1

      How about a lye burn?

      --
      Any sufficiently advanced intelligence is indistinguishable from stupidity.
    39. Re:Synergy, leverage, low hanging fruit, etc.. by Anrego · · Score: 1

      Well, a bug doesn't necessarily have to be discovered by someone getting killed, or even be a bug that could lead to someone getting killed

      my point was more that in life critical systems, the testing and approval phases are massive, often many times the cost of the initial development, and depending on the situation, a 2 line code fix might require the entire system to be re-tested and certified.

  3. Yes! by Omnifarious · · Score: 5, Interesting

    Code reviews have a lot of value in two ways completely independent of how good they are at catching errors. First, they are a way to enforce various stylistic guidelines on code that make future maintenance much easier. Secondly, they are a tool for spreading knowledge about the code around to other members of your development team.

    They can also catch some errors that are very hard to catch in any other way. I recently worked on a project in which I found an error that would've caused code to only fail in a very limited and non-obvious set of circumstances. The thing is, somebody would've almost inevitably encountered those circumstances and the phantom and nearly unrepeatable bug reports resulting from this would likely have never been solved.

    I fear code ever stepping off into the land of incorrect behavior as there are few corrective mechanisms that will cajole the errant program back into doing something sane. The longer it goes without abject failure, the more weirdly wrong it will be. Therefore I think any and all measures to keep it from ever going there and making sure it dies as quickly as possible if it does are useful.

    1. Re:Yes! by Gorgeous+Si · · Score: 2, Interesting

      Where I work, we have code reviews before checking in non-trivial changes. We don't have design reviews though, which I think are more worthwhile. If a problem is found pre-checkin, then it's usually too late to go back and re-code the work - meaning that these issues are recorded by the coder and should be looked at again when possible; however, with the constant deadlines we work to, there often isn't time to go back and make the improvements. I think design reviews are worthwhile for verifying the work that's going to take place, and a code review should be used to see if it matches the design (and find out the reasons if not), as well as making sure that the checkin isn't going to screw up the build (check for warnings, files missing from changelist etc).

    2. Re:Yes! by ers81239 · · Score: 2, Interesting

      I just want to highlight your second point. I believe that THE most important thing gained from code reviews is the spreading knowledge and gaining understanding. New development is always great, but most programming is maintaining/fixing/improving existing projects. A code review is a great way to really learn about code readability. You actually get to see other people read your code and you get to read other people's code. All of this code is fresh in someone's mind so it can be explained, and how to make it more readable can be discussed. I learned a ton about writing maintainable code at my first job where we did regular code reviews.

      On the more technical side, often once the code is discussed much simpler ways to solve the problem is discovered. It isn't about the individual bug fixes/improvements that can come from a code review. Its really a way to improve your programmers.

      --
      there are 2 kinds of people. those who divide people into 2 kinds, and those who don't.
    3. Re:yes! by GeckoAddict · · Score: 2, Insightful

      Your last part I think is one of the most important. Making sure at least two Full-time employees (not contractors, not interns) know the code is extremely important in making sure that someone can answer questions should one leave/be out sick/etc. You also ensure that any assumptions you made about other parts of the system or other libraries are indeed correct, and you ensure code is using best practices for both performance and language standards. The key to code reviews is making sure it's a quick iterative diff of a few files, and not a room full of engineers looking at 50 files on an overhead projector. Our workplace recently instituted a new policy of 'every task/commit must have a code review' (it's actually a property of the task in our code management tool so it's easy to query), and it's helped us catch a lot of bugs before test ever sees it. A 5 minute fix from a code review is a lot better than finding it in test: spending 2 hours trying to dig through the logs to find the bad code, fixing it, and rebuilding everything so test can continue. Not to mention the code is a lot cleaner and a lot more optimized with a few people looking at it.

    4. Re:Yes! by crispytwo · · Score: 1

      Code reviews have a lot of value in two ways completely independent of how good they are at catching errors. First, they are a way to enforce various stylistic guidelines on code that make future maintenance much easier. Secondly, they are a tool for spreading knowledge about the code around to other members of your development team.

      They can also catch some errors that are very hard to catch in any other way.

      I agree, however, what I have implemented in my shop is before a commit to the repository is made, two programmers sit together and go through every line of code being committed (and of course the surrounding code). What that does is a minimal code review (i.e. only two people involved). However, it does allow the transmission of knowledge, improves style, catches all sorts of interesting bugs and all for minimal cost. It doesn't catch everything, but neither does a grand code review.

      Everyone that does this type of thing actually appreciates it and is willing to do it. Specifically, no one complains about how much extra time it takes and what better things they could be doing. I recommend this as something that can be added to your development cycle and do grand code reviews too, when budget permits.

    5. Re:Yes! by dhavleak · · Score: 1

      Absolutely dead right.

      Code reviews also have an important place in secure development processes. It's important to train all your devs on secure development practices and then have them look for insecure coding while reviewing code. It's not a substitute to having a security expert (in-house or consultant) audit your code - but it's still a valuable step to catch low-hanging stuff like silliness with string buffers, absent-minded sizeof calculations (that could lead to buffer overrun vulnerabilities), etc.

      Another common defect that tends to be caught in code reviews -- memory leaks. It's nothing that a half-decent stress test won't catch, but I've seen a lot of companies do very half-assed testing with no proper stress testing / leak detection etc. It's relatively common to see a developer forget to close a handle, or absentmindedly use the wrong function to close a handle (happens when using non object-oriented APIs with multiple handle types and consequently multiple handle closing functions) -- this is exacerbated by the fact that people rarely check the return status of a close-handle call. Sometimes even memory allocation/deallocation issues get caught in code reviews.

      And of couse, that's no substitute for proper stress testing / memory profiling / leak detection.

      I've found that the best way to maximize what you're getting out of code reviews is to give some thought to what benefits you could get out of it (for example, if you're developing in C# you can toss out the string buffer stuff above, but you can add stuff like dereferencing..). Obviously you should solicit input from all your devs in this step. Next, you should compile that information into an informal guideline (or rather "'things to keep in mind checklist") that people can pin to the wall. Take 10 seconds to scan the list before doing a code-review -- it helps align your thoughts in terms of what you're looking for in the code review.

    6. Re:Yes! by gnasher719 · · Score: 1

      Where I work, we have code reviews before checking in non-trivial changes

      The worst bug I ever had to search for happened because a trivial change wasn't code reviewed. A simple line "if (ptr != NULL)..." and one exceedingly "clever" developer decided that this was too many characters, so he changed it to "if (! ptr)..." and because the change was trivial, and because that developer was so clever, it was checked in without a code review.

    7. Re:Yes! by Anonymous Coward · · Score: 0

      This is especially true if you have a wide mix of skill levels in your development staff. It is a must if you have new programmers right out of college or contractors.

  4. In a word, yes by iamdjsamba · · Score: 3, Insightful

    Where I work we have code reviews at various degrees. I find someone else just reading over my code and emailing suggestions helps tons; It spots obvious errors, ways code could be done better, and just a ton of other things. It helps improves my own coding style too.

    --
    http://studentseeksnoodles.blogspot.com: General thoughts of an
  5. When done right by El_Muerte_TDS · · Score: 4, Informative

    Code Reviews are useful when they are done right. But before you start using code reviews you should introduce automated static analysis of the code during the builds. A lot of crap can be discovered by static analysis. This saves you a lot of effort on the tedious parts of code reviews.

    1. Re:When done right by tkw954 · · Score: 1

      Code Reviews are useful when they are done right.

      That's why Code Review Reviews are necessary. Of course, Code Review Reviews are only useful when they are done right.

  6. If you're code review is taking forever... by ciroknight · · Score: 4, Insightful

    then you're doing it wrong. Plain and simple.

    Code reviews shouldn't be a "full stop, let's go over this" event. Code review should be a part of the every day workings of the development team. Nothing should go into version control's master/trunk/HEAD until it has been reviewed.

    Sometimes you'll find that stopping to review a single module is helpful, but most of the time it's actively harmful to the team, since it takes developer's concentration off of what they're currently working on to review things that they half-don't-remember, which then makes the code review take forever.

    Review and document inline with your coding, and you'll find you'll never need a "Full Stop" review.

    --
    "Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is." G.W.Bush
    1. Re:If you're code review is taking forever... by pankkake · · Score: 2, Funny

      Grammar Nazi to the rescue: If your code review

      --
      Kill all hipsters.
    2. Re:If you're code review is taking forever... by sakdoctor · · Score: 1

      My code is self reviewing.

    3. Re:If you're code review is taking forever... by ciroknight · · Score: 1

      Ahh the quick typist tripped over the lazy dog. Missed that one. Sorry.

      --
      "Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is." G.W.Bush
    4. Re:If you're code review is taking forever... by SixAndFiftyThree · · Score: 2, Insightful

      If I'm code review is taking forever, it's because I haven't documented I'm code. So in a culture of constant code reviews, I remember to document. Adding comments no longer wastes time; it *saves* time in the pretty near future. I also write fewer lazy hacks than I used to, because of the fear of having to explain them. And my code gets better for other reasons mentioned on this thread.

      The OP didn't explicitly say that they were reviewing code months after it had been written, but no, archaeology and programming don't mix any too well. OTOH in a company where Hitting The Release Date is all-important, there is certainly a temptation to postpone until after that Date everything that can possibly be postponed, and pointy-haired types do think code review (and documentation) can be postponed.

      What would you say to a teenage boy who thought putting on the condom could be postponed until after the ... release?

    5. Re:If you're code review is taking forever... by Anonymous Coward · · Score: 0

      ABSOLUTELY RIGHT!

    6. Re:If you're code review is taking forever... by ciroknight · · Score: 2, Funny

      Nobody was talking to you, Skynet.

      --
      "Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is." G.W.Bush
    7. Re:If you're code review is taking forever... by Keybounce · · Score: 1

      > Review and document inline with your coding, and you'll find you'll never need a "Full Stop" review.

      My best experiences with "code review" is working in a team of two programmers to one terminal. If you have to go over every decision with someone else, and there's always someone else familiar with every section of code, then that's great.

      Double the programmer cost of development may seem high, but that's only something like 1/6th the total cost, and it lowers the bug fixing cost.

    8. Re:If you're code review is taking forever... by DoofusOfDeath · · Score: 1

      Code reviews shouldn't be a "full stop, let's go over this" event. Code review should be a part of the every day workings of the development team. Nothing should go into version control's master/trunk/HEAD until it has been reviewed.

      I don't think that's true. Sometimes projects, especially new ones, are in phases where many ideas get tried out, partly to see how to best tackle a problem, and partly to tease out requirements. When you have a small number of people working in that mode, and the trunk is intended to be a bit like the Wild West, code reviews can probably wait a while.

    9. Re:If you're code review is taking forever... by ciroknight · · Score: 4, Insightful

      Small projects in the stage of trying things is roughly the definition of drafting a design.

      And quite frankly, if you don't draft the design correctly from the beginning, it can cause huge problems later. Some projects can skip this step and do iterative design (most open source projects, software libraries, e.g.), but commercial products typically don't have the luxury of having a product delayed by a huge amount because someone's design was wrong and it is now a burden to remove and replace.

      Not stopping to design for the future early on is the reason Xorg is a complete and absolute clusterfuck today, for example.

      --
      "Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is." G.W.Bush
  7. They sometimes find really difficult problems by Anonymous Coward · · Score: 3, Interesting

    When we did code reviews at DEC, they were done with several people generally familiar with the code, required considerable advance prep by the reviewers, and went over code basically line by line. This was not done for all code; nobody had time or resources. However, when a piece of code was doing something weird, it was a pretty effective way to figure out what might be wrong, where the programmer had been having trouble finding a problem. The one area where it tended not to work well was where the software was a driver that talked to some piece of hardware, and the programmer was the only one who really knew what the hardware was doing. The fact that the reviewers didn't know that hardware made finding bugs most difficult...

  8. U R DOIN IT WRONG :) by RealTime · · Score: 5, Insightful

    What we've found is that code reviews take forever...

    Ugh. Are you reviewing each individual commit (where code reviews are quick and very effective), or are you rounding up a bunch of developers in a conference room and reviewing an entire module using an overhead projector?

    Peer-to-peer reviews of individual diffs using good workflow tools have been very effective at several places I have worked and in open-source projects to which I have committed.

    Some of the fastest team development velocity I have experienced has been with peer code reviews within the team.

    A good style guide also helps...

    --

    Yesterday it worked; today it is not working; Windows is like that...

    1. Re:U R DOIN IT WRONG :) by Qubit · · Score: 1

      Peer-to-peer reviews of individual diffs using good workflow tools have been very effective at several places I have worked and in open-source projects to which I have committed.

      This is basically how we work at my lab. Anything going into the master branch of our multimedia engine needs peer review; anything going into a multimedia project needs peer review after we've hit beta (roughly speaking).

      In my experience code review is a very helpful part of development. It often catches stupid errors and can be an important piece of keeping the programming team abreast of everything that's going into the codebase.

      If you don't like unit tests (or at least the idea of writing unit tests -- I often fail at writing them before I write my code), then you might consider peer review of code a big hassle. Personally, I think the benefits are well worth the cost.

      --

      coding is life /* the rest is */
  9. Line them up by Anonymous Coward · · Score: 5, Funny

    Have each developer line up with his/her/its code printed out on a cue card board and stand in a line up. Execute the least likely to make it to the compiler, then you will "motivate" the rest to write better code..

    1. Re:Line them up by xded · · Score: 1

      Shouldn't you let the code make it to the compiler before executing it?

    2. Re:Line them up by Anonymous Coward · · Score: 0

      I guess you say something like
      "This code looks awful! Let's see what happens when we execute it.
      BLAM
      "Yep, see that? That's what happens when you execute bad code.

  10. Signs point to yes by ucblockhead · · Score: 1

    My group started implementing code reviews this month. To get in the swing of things, we decided to do a test review of existing foundation code, stuff that had been in the product for many months, had gone through multiple QA cycles, and had been shipped to the customer as part of the first "production" release.

    In the first hour-long review, we found a number of significant issues, and one full-blown bug.

    --
    The cake is a pie
    1. Re:Signs point to yes by maxume · · Score: 1

      So...good thing or bad thing?

      --
      Nerd rage is the funniest rage.
    2. Re:Signs point to yes by uncqual · · Score: 1

      and this requires an answer? :)

      If a "coder" fixes a bug it costs X.

      if a "reviewer" catches a bug it costs 10X

      if "QA" catches a bug it costs 100X

      if a Customer catches a bug it costs 1000X

      Oh... do I have stories from the crucible of systems development...

      --
      Why is there an "insightful" mod and why isn't it "-1"? If I wanted insight, I wouldn't be reading /.
  11. Depends on what you're looking for by ipoverscsi · · Score: 4, Interesting

    Design reviews are useful to catch problems early on, particularly the selection of poor algorithms or data structures. However, in the the software shops I've worked nobody does any documentation, which makes it particularly difficult to do a design review. So, as you can imagine, I haven't got much experience with this area.

    Code reviews, on the other hand, are more about auditing code to make sure that people are following the coding standards and policies. After all, if you've got coding standards, how are you supposed to tell if anybody is following them without reviewing the code? Once your coding standards have been institutionalized -- that is, most people have internalized them and following them -- then what's the point of a code review?

    So your best bet, then, is to reserve code reviews for junior developers until the coding standards are internalized; and use design reviews for the architects.

    1. Re:Depends on what you're looking for by jonaskoelker · · Score: 1

      After all, if you've got coding standards, how are you supposed to tell if anybody is following them without reviewing the code?

      Version control hooks---if the standards are codified and easily machine-verifiable.

  12. Why is this not under Ask Slashdot? by Anonymous Coward · · Score: 0

    Just wondering

    1. Re:Why is this not under Ask Slashdot? by hedwards · · Score: 1

      Because they didn't do a code review.

  13. Yes, yes, and then some by QuoteMstr · · Score: 5, Informative

    Even the best programmers make mistakes. Having another set of eyes is invaluable for detecting bugs before they become problems. Having to explain in words the rationale for a design decision often helps you better understand your own design, and to see potential problems with it. Sometimes you come up with something better on the spot. Also, if you get hit by a bus, your fellow programmers can take over without having to reverse-engineer your thoughts. Please, more code reviews.

    1. Re:Yes, yes, and then some by readin · · Score: 2, Insightful

      Also, if you get hit by a bus, your fellow programmers can take over without having to reverse-engineer your thoughts.

      But if I get hit by a bus, I won't care whether my fellow programmers can take over without having to reverse-engineer my thoughts.

      --
      I often don't like the choices people make, but I like the fact that people make choices. That's why I'm a conservative.
    2. Re:Yes, yes, and then some by paazin · · Score: 4, Insightful

      But if I get hit by a bus, I won't care whether my fellow programmers can take over without having to reverse-engineer my thoughts.

      But the company that gives you that paycheck does, and that's all that really matters. :)

    3. Re:Yes, yes, and then some by readin · · Score: 1

      But the company that gives you that paycheck does, and that's all that really matters. :)

      If I get hit by a bus, will they keep giving me a paycheck?

      --
      I often don't like the choices people make, but I like the fact that people make choices. That's why I'm a conservative.
    4. Re:Yes, yes, and then some by FrozenGeek · · Score: 1

      True. But if one of your co-workers gets hit by a bus, you'll be glad that you can takeover his work without having to reverse-engineer this thoughts. What goes around comes around.

      --
      linquendum tondere
    5. Re:Yes, yes, and then some by paazin · · Score: 1

      If I get hit by a bus, will they keep giving me a paycheck?

      Possibly, if you were busy coding for them at the time and a bus owned by the company smashed through your cube, rendering them liable. ;)

    6. Re:Yes, yes, and then some by Anonymous Coward · · Score: 0

      Let's go further down the holistic work ethics worm hole...

      Do I care what the company that gives me my paycheck thinks it's paying me to do? :)

      (assuming for a moment that officers of said company have little or no ability to and/or interest in discovering the alleged discrepancy between what I do and what I'm being paid to do)

  14. Depends... by cdrguru · · Score: 4, Insightful

    As someone else noted, badly-run code reviews aren't worth much, if anything.

    There was a lot written about code reviewing in the late 80's and early 90's that makes sense. If a review is conducted as a lesson in coding to others, nobody is going to get much out of it. If it is done as a last-ditch design review, that probably isn't going to work out well either.

    If the staff is all people with lots of experience, it may not be that valuable. Alternatively, I see it as an extremely powerful tool for a staff that works mostly independently to come back together periodically and make sure everyone is on the same page. Especially when some team members have less experience.

    Trying to bog it down with formality is pointless. But the early guidelines about "egoless" are right on target.

    1. Re:Depends... by hedwards · · Score: 1

      Not to mention the incentive that regular reviews provide for concise and well documented code. I can't imagine some of the examples I've seen of comments run amok or code only understandable at the Balmer peek.

      Code reviews aren't going to solve that by themselves, but if you're looking at the code as part of a program of review on a reasonable basis, it's harder for bits to fester in odd corners of the repository.

    2. Re:Depends... by Cyrano+de+Maniac · · Score: 2, Insightful

      I pretty much agree with the parent.

      When I was fairly new to my company code reviews were reasonably helpful, as I was certainly not an expert in the areas I was fixing bugs, and there was a lot of undocumented knowledge of how various components interacted with eachother. As time went on and I became more proficient in these areas, code reviews began to be less useful.

      I then moved on to taking primary responsibility for an important system library whose original developer left years earlier, and the current maintainer had been layed off. A year into that effort I was effectively the only person in the company who understood how the library worked, and as such was the sole expert on it. Code reviews for checkins were still mandatory, but about the only thing any other reviewer would ever find were minor stylistic issues -- the real bugs went undetected because the expertise required to detect them just wasn't reasonable to expect of anyone else.

      Today I find myself working on deep close-to-the-metal code. Due to economic conditions it's just not feasible to have any overlap between engineers in the areas they're deeply familiar with (yes, that's a management issue -- city bus syndrome is a very real risk). For all but the smallest changes, others cannot fully understand the implications of my changes when they review my code, and I cannot understand the implications of the changes when I review their code. We still keep at it, but the effort rarely catches real problems.

      Alongside those issues, I have been with this company for more than ten years, yet in my particular group I'm the youngest person with the least experience. With such a mature and historied team, significant mistakes are exceedingly rare, and even minor mistakes are uncommon. The most common thing we catch is someone forgetting to update the current copyright date in a file's comment block.

      For the stated reasons, I currently view code reviews as generally just an extra hoop to jump through in the checkin process. If I should ever change jobs, I'm sure I'd once again appreciate having more experienced developers double-checking my efforts.

      --
      Cyrano de Maniac
    3. Re:Depends... by Anonymous Coward · · Score: 0

      Hells Yeah!

      As a junior Intern, I looked forward to all code reviews, I learned a whole lot of cool ways to do things more cleanly and awesomely from intense code review sessions.

      These are the sorts of things you can't learn from books or other sources, even from the flagship books on coding like Code Complete.

      Cheers,
      n00b intern.

  15. They are worth it by Stevecrox · · Score: 4, Insightful

    Where I work we do code reviews and they are definitly worth the time. 60% of the time the review doesn't flag anything. But by having anouther coder look at the code you can find those points when a comment would be very usefull, where an algorythm might break down to simple typo's , complexity issues and general readability

    Code reviews are as much about code maintainability and ensuring the code follows standards then finding bugs.

    1. Re:they are worth it by cetialphav · · Score: 5, Insightful

      If you are shipping bugs your problem is testing, not code reviews.

      No, no, no. If you are shipping bugs the problem is that the bugs are introduced in the first place. Blaming testing is not getting at the root cause of the problem. You cannot test quality into a product. I've worked on products where tons of bugs were shipped and people wanted to blame the test group, but the fact is that the test group wrote tons of bug reports that no one had time to look at much less fix. Pretty much every bug report that came from the field had already been found internally. When testing started, the product was already so crappy that a few bug fixes just were not enough.

      As a CS person, I view the Software Engineering research discipline with quite a bit of skepticism. But one thing that the research is pretty clear on is that code reviews do work. If the submitter is not seeing that, then he is either on the verge of a major research breakthrough that invalidates decades of SE research or he is doing them wrong.

    2. Re:they are worth it by murdocj · · Score: 1

      You're talking about something different from what the GP was talking about. If testing is uncovering bugs, but engineering isn't fixing them, the problem is neither a lack of code review or testing quality, it's an organizational problem that no technique is going to fix.

    3. Re:they are worth it by Matheus · · Score: 5, Insightful

      I'll add a few more.. no, no, no, no, no...

      Your argument is valid but does not actually counter the original statement. The testing team apparently did their job and found the bugs in the system. Yes, it would be nice if the original coders hadn't done such a great job of creating these bugs BUT this is not the problem (and in reality tends to not be feasible at least in total.. you can minimize bugs but rarely if ever eliminate their creation)

      The problem is that the testing wasn't utilized! If the sole job of a testing team is to submit bug reports that can be ignored then why have your testing team? Save the money and just ship the first raw release. This product should have never made it out the door until those bug reports were resolved in some fashion (even if that "resolution" is marking the bug as "release acceptable, fixed in next version/patch"). In this case I would say it is the release team OR probably the management's fault that these bugs made it to the consumer. They paid a lot of money on a testing team and then ignored their feedback and cost themselves even more in customer dissatisfaction and support calls for bugs *they already knew about*.

      Wasteful.

    4. Re:they are worth it by cetialphav · · Score: 1

      I don't argue that there was plenty of blame to go around, including at management. In some cases, there were contractual obligations to deliver the product by a certain date. Failure to deliver would mean penalties of hundreds of thousands of dollars per week. By the time people figure out the state of the system, you have a mountain of bugs and a contractual deadline bearing down on you. There really aren't many choices you can make at that point.

      But all of that is why telecomm sucks and why the stock prices of most telecomm companies is in the toilet.

    5. Re:they are worth it by cetialphav · · Score: 2, Insightful

      What I am saying is that you cannot just throw some sloppy code together and expect to fix everything up in the test process. When you try to do that, you get an endless mountain of bugs. Since the code is so bad, each bug fix just causes additional bugs because new test cases get opened up (or because of unexpected code interactions). When you plan on 2-3 months of testing and it is 8 months later with no end in sight, you start to understand why people just hold their nose and release to customers.

      If you want a quality product delivered on time, you have to start by constructing the code with quality in mind and code reviews are an important part of that.

    6. Re:they are worth it by Anonymous Coward · · Score: 0

      I read testing as component tests, which developers write. I would agree that testing in that form, not reviews, is the bigger lacking in most organizations. I've been in both projector style reviews and commit-driven reviews, with only the latter being useful in fine-tuning. The fact that most developers do not consider unit tests to be manditory and part of the development process is the root cause for most bugs that I've encountered. Almost all bugs that our found in my code are found by me and I can't recall the last time that a bug of any significance was caused in code that I owned and was found by QA. However, I constantly am asked to help other teams drain their bug queue and fix problems because the code has no tests. Its downright depressing work. If bugs make it into production that are P1 or P2 level then the owners should be embarrassed. Unfortunately at most organizations, fixing production makes one a hero and promotes building garbage in order to get a pat on the back.

      So the GP is right - the problem is most likely testing. And you're right too - testing isn't the fault of QA. In fact just having a test group that validates bugs indicates process problems to me.. (and yes, my employer has a big testing group and the product is garbage due to the poor quality, even on new code, allowed in)

    7. Re:they are worth it by Dragonslicer · · Score: 2, Funny

      No, no, no. If you are shipping bugs the problem is that the bugs are introduced in the first place.

      Can I come live in your fantasy world where programmers write perfect code every time?

    8. Re:they are worth it by Tanktalus · · Score: 2, Interesting

      Just because it's fantasy (and it is) doesn't mean that's not the best/cheapest way to quality. The cost of fixing something in QA vs the original development is significant. Depending on who you believe (which study), it can be 2-10 times the cost. We'll be pessimistic(ish) and say 3x. That's basically enough to pay for pair programming, actually, which probably would be as cost-effective at producing quality as having the QA team. A bit of usability testing is about all that's left that developers are no good at (you've spent months focused on the problem, of COURSE it looks intuitive to you!).

      Not that we do this at $work, of course. That's crazy talk.

      /me sighs

    9. Re:they are worth it by cetialphav · · Score: 3, Insightful

      Why do you think I live in a fantasy world? I'm just talking about the root of the problem. The root of the problem is that writing software is hard and programmers are human and make mistakes and those mistakes result in bugs. If you can reduce the rate at which bugs are introduced, you gain a huge increase in quality and a huge reduction of cost because fixing bugs after they are introduced is very expensive.

      It is a fact that there are known practices that result in better code in the first place and code reviews are one of them. It is also a fact that many companies do not use these practices and hope that the testing team can pick up the slack.

      So the management question is where to spend resources to improve quality and meet deadlines. Do you just add more and more testers so you can find the bugs faster and faster? Do you throw more coders at the problem so you can get the crappy code to the testers earlier? Do you adopt some of the practices that are known to work like reviewing code even though it means some of your coders will have to spend their time not actually writing code?

      Since most companies continue to do stupid things that don't work, you tell me who lives in a fantasy world.

    10. Re:they are worth it by kloffinger · · Score: 1

      In all seriousness though, just because programmers aren't perfect doesn't mean you shouldn't review their work products. Think of the excuse "oh programmers aren't perfect so let's skip reviews" - why don't you also say "oh well humans run tests, and humans aren't perfect, so we should skip the tests too, just ship it." Code reviews are a form of testing (on the upward slope of the V-model). Testing should not be skipped, although yes it can be argued that the worthless tests should be skipped. At risk of repeating what a lot of people have said in this discussion already, tests shouldn't be discarded just because they're painful - they should be discarded if metrics show they're worthless.

    11. Re:they are worth it by murdocj · · Score: 2, Interesting

      I don't disagree at all. But my experience is that pretty much everything depends on the attitude of the overall organization. I worked at a company where we developed individually, with some consulting back and forth. We'd pull people in to try to diagnose problems, but generally not what you would call pair programming or code reviews. The product was solid... not 100% bug free, but certainly a quality product that was enhanced over many years. That was the result of an organizational attitude that we were going to ship a quality product.

      Eventually we got bought out by a "we are hot java programmers, unit testing rah rah rah" company, and they shipped utter crap. They always had the attitude that "hey it has to ship, we'll just stay up late and jam all nite and ship the disk, and by the time they load the disk, we'll have a fix version". I was actually on a call where people were laughing about how the contract said we had to ship a disk by a particular date, but didn't say it had to work. No technique on the planet could have saved their product.

    12. Re:they are worth it by Alex+Belits · · Score: 1

      Of three procedures that can improve quality of code -- writing, reviews and testing -- the first one is far more reliable than the rest. There is only one way to find a bug that already exists in the program in testing -- by an accident that it happens to be covered by a test case. What usually means, tests are written by a more intelligent person than the developer (and then why isn't that person a developer in the first place?). Reviews are better, however they rely on reviewer's ability to not only recognize what developer is trying to do but also to find situations where this intention does not match what the code actually does. What often is even more difficult.

      --
      Contrary to the popular belief, there indeed is no God.
    13. Re:they are worth it by n8r0n · · Score: 1

      the cheapest way to do code reviews is for a manager to just scan submitted code from time to time and send out polite emails if they see something amiss.

      If this works for you, then you've got a hell of a lot better managers than most of the software world. I'm not sure I'd want to leave this responsibility to the guys with pointy hair.

    14. Re:they are worth it by CarbonShell · · Score: 1

      I would tend to agree with you that it is not directly the testing teams fault. They can only react upon what has been developed.

      If I have a cleaning lady, do I check every corner, under every rug and in each bin to see if they did their job correctly?
      The first time probably and react upon this, depending on the outcome. In the ideal situation you might later just do casual inspections.

      From my experience the quality is often simply pushed off to the testers because 'they have to test it anyway', when IMHO the testers are the final quality gate before the customers.
      I have even had situations where testers were so busy 'finding' (not really had to look hard to find them) idiotic bugs that *anyone* could have seen and when they finally got around to the deeper and more critical bugs, we were already past our deadlines.

      I would not blame the testers for issues they missed. If anything they would get a glancing blow from the slap the developer gets.
      The only requirement I'd have is that we find out how it was missed and how we can improve.

      IMHO quality starts at the bottom: the single coder and goes all the way up.
      F.i. Jr developers need closer supervision
      ('normal') developers are subjected to occasional reviews. these have proven to have improved the quality of their work.
      lead developers (who could do the reviews and supervision of those above) have proven their reliability and might only have to answer to architectural reviews.

      Yes, even if the code is perfect you could still have different problems but these would be issues for the architects.

      I even go as far as to demand proof that a bug is not inside someone's component.

    15. Re:they are worth it by hesaigo999ca · · Score: 1

      I agree with you 100% on this matter, it usually is a matter of decision by upper management, when to ship and if we ship with bugs or not. Regardless of if our testing team found stuff, they get the "I don't want to hear it" attitude, and it falls to the way side, until someone goes, "hey why didn't you tell us this,.....ahem ya that's right you DID!"...usually that's when heads roll in the admin department...lol.

    16. Re:they are worth it by Anonymous Coward · · Score: 0

      I find it funny that you said that you cannot test quality into a product but then said that the test group had found all of the bugs before the product was shipped.

  16. PCI-DSS Code Reviews by Anonymous Coward · · Score: 3, Interesting

    Part of the PCI-DSS (Payment Card Industry Data Security Standards) security requirements is to conduct quarterly code reviews of applications that process credit card data, or put an application firewall on your network to monitor these applications.

    Like most companies, we spent about 10 minutes working out how much time our developers would have to spend on this per quarter - and then we decided to drop $30K on the firewall.

    1. Re:PCI-DSS Code Reviews by Anonymous Coward · · Score: 0

      A place I worked at that shall remain unnamed would try to work around the PCI-DSS rules.

      The firewall? Yep, they had one. It was a $1k Linux box passing all traffic through, basically.

      The key-card encryption? They technically "owned" the encryption box. Which is probably to this day sitting in the cage at the data center without power running to it, much less data.

      One of those sleazy companies that yells at its employees to get more done faster, but refused to spend a dime to do it. Results of that are pretty predictable...

  17. If you did test-driven development by Jane+Q.+Public · · Score: 1, Interesting

    then code reviews would be redundant. Sure, testing first is expensive. But probably no more expensive than code reviews. If you have a QA person or team checking the final product, then your bases are covered.

    1. Re:If you did test-driven development by hedwards · · Score: 2, Insightful

      Stupid question, but doesn't that miss things which are technically OK, but likely to lead to problems down the road? Things like poor naming conventions, improperly formatted or under documented code.

    2. Re:If you did test-driven development by Nerdfest · · Score: 1

      It is not redundant. You can use TDD and still have developers that write unmaintainable crap.

    3. Re:If you did test-driven development by radtea · · Score: 3, Interesting

      then code reviews would be redundant.

      Err... no. Testing is not a replacement for code reviews, which do a variety of things, including enforcing coding and commenting standards, act as sanity checks in implementation of design, etc. They also find the bugs that you never thought to design tests against.

      Test driven development is a good way of capturing requirements in testing up-front, rather than leaving that as a downstream activity the way conventional testing is done. Doing test-driven development will not cause your test set to be any more thorough than a properly done V&V test set.

      A while back on /. we had a story about a serious bug in a major product (can't remember what it was) and someone commented that "this seems like the kind of thing that test-driven development would have caught" as if the tests the developers would have thought of doing in a test-driven environment would have been any different than the tests developers would have thought of doing in an environment with sane down-stream testing. There is absolutely no reason to believe this.

      --
      Blasphemy is a human right. Blasphemophobia kills.
    4. Re:If you did test-driven development by Jane+Q.+Public · · Score: 2, Interesting

      Naming conventions are overrated. Most programmers outside Microsoft have thrown Hungarian notation out the window, and other forms as well. If your code is well-written in the first place, most naming conventions are simply verbose redundancy. It's an old-school habit that is largely no longer necessary or followed. (Of course, that does depend on what kind of coding you are doing. If you are still doing C++ in Visual Studio 3 you might want to stick with it.)

      Second, modern tests are documentation. For example, if you were using rspec for tests, you can do (this is pseudocode):

      Method "MyMethod" should do {this}.

      Method "MyMethod" should do (that).

      Method "MyMethod" should not do (something else).

      Method "AnotherMethod" should do (yet another thing).

      This is very straightforward, and does not tend to "lead to other problems down the road".

      Having said that, these kind of tests are for code, and often not for overall user experience. If you want to test your interface, you might want to use other tools. And nothing replaces a good QA person or team to test the final product.

    5. Re:If you did test-driven development by Jane+Q.+Public · · Score: 1

      Okay, I admit that I may be biased, but I disagree. If you have "commenting standards" at all, for example, that is an indication you are not using modern programming methods.

      No, test-driven-development is not perfect. But it's a hell of a lot better than pretty much anything else that has so far been devised. And code reviews do not tend to catch many coding mistakes that TDD misses... but QA can.

      "A while back on /. we had a story about a serious bug in a major product (can't remember what it was) and someone commented that "this seems like the kind of thing that test-driven development would have caught" as if the tests the developers would have thought of doing in a test-driven environment would have been any different than the tests developers would have thought of doing in an environment with sane down-stream testing. There is absolutely no reason to believe this."

      While I admit that I am generalizing, that is generally not true. There is every reason to believe that. If you are properly doing test-driven development, you are not just testing what you happen to think of regarding major functions or modules. TDD involves nearly every line of code you write. Modules, classes, methods, etc... often down to the single-line-of-code level. "Test-driven" means you do the tests -- based on the desired behavior of the code -- BEFORE you write any code to actually do it. And you write negative tests, to catch edge cases or unwanted behavior, as much as you do positive tests. In other words, it keeps the programmer thinking about not just the desired but also the UNdesired behavior of the code. TDD catches a lot more than traditionsl QA, by its very nature, because it is testing at a low level, while QA and after-tests generally test at an interface level. It is QA and after-tests that tend to miss more.

    6. Re:If you did test-driven development by Jane+Q.+Public · · Score: 1

      Then you have coders who belong elsewhere. Why put up with that?

      ANY kind of programming can be done sloppily or poorly. That is not an argument for or against any particular methodology.

    7. Re:If you did test-driven development by Anonymous Coward · · Score: 0

      Okay, I admit that I may be biased, but I disagree. If you have "commenting standards" at all, for example, that is an indication you are not using modern programming methods.

      I'd say the complete opposite is true. Some modern languages even have built-in enforceable commenting standards. Most development communities also adopt or invent some kind of standard (Doxygen, gtk-doc, java-doc, C#'s inline XML documentation, the list continues).

      No, test-driven-development is not perfect. But it's a hell of a lot better than pretty much anything else that has so far been devised. And code reviews do not tend to catch many coding mistakes that TDD misses... but QA can.

      Code review is quality assurance, plain and simple. If your development and QA teams are leaving out code review, fire them and hire in a new team. TDD will never catch quite a few problems that other human beings will notice instantly as glaring problems, simply because the tests are not human beings; they're written by human beings, and are just as likely to have errors themselves if not properly reviewed.

      "A while back on /. we had a story about a serious bug in a major product (can't remember what it was) and someone commented that "this seems like the kind of thing that test-driven development would have caught" as if the tests the developers would have thought of doing in a test-driven environment would have been any different than the tests developers would have thought of doing in an environment with sane down-stream testing. There is absolutely no reason to believe this." While I admit that I am generalizing, that is generally not true. There is every reason to believe that. If you are properly doing test-driven development, you are not just testing what you happen to think of regarding major functions or modules. TDD involves nearly every line of code you write. Modules, classes, methods, etc... often down to the single-line-of-code level. "Test-driven" means you do the tests -- based on the desired behavior of the code -- BEFORE you write any code to actually do it. And you write negative tests, to catch edge cases or unwanted behavior, as much as you do positive tests. In other words, it keeps the programmer thinking about not just the desired but also the UNdesired behavior of the code. TDD catches a lot more than traditionsl QA, by its very nature, because it is testing at a low level, while QA and after-tests generally test at an interface level. It is QA and after-tests that tend to miss more.

      If your tests are thorough enough to test every written line of code, then it's likely you have more tests than code and your test suite will likely take a very long time to run, meaning it won't get ran often enough. And I've seen this both personally and in other's reports; people who believe too strongly in tests will find glaring errors in code that passes all of the tests, and can spend so much time wondering how the tests passed and coding on new tests to attempt to find the error that the bug itself gets forgotten and pushed to the wayside. (This happens a lot in one of the Java communities I used to be a member of, which is part of the reason I am no longer a member.)

      TDD is an important part of development practices, but it is not the holy end-all that you're making it out to be. This is the real problem with it these days. Even the books on the subject are doctrines of drivel and don't discuss how it fits in with other sane development practices like code review, pair/team programming, distributed programming, etc.

    8. Re:If you did test-driven development by ivan256 · · Score: 1

      TDD is a great theory.

      In practice you spend 200% longer to generate your product. You end up with the same bugs you would have had before, but you have to fix them in the test and the software. Plus you typically end up getting to run the same test 10,000 times against the same piece of code, 'cause it ends up getting run whenever you build.

      I'm not talking about stupid little think-os, syntax, or functional type bugs. TDD can catch those fine, but so can a good code review... I'm talking about the real bugs that eat the majority of a release cycle (yeah, I know. To a manager every bug is just one more in the bug count). I'm talking about bugs where the developer didn't know the correct functionality, or thought they knew the correct functionality but didn't take into account some outside effect (any possibly couldn't have predicted the outside effects ahead of time).

      Good developers know the appropriate level of testing, whether a particular module would benefit most from a unit test, an integration test... Whether it would be best done manually, or automated... Enforced test-driven development, though, just guarantees doubled implementation time and results in a whole bunch of tests of basic operators and constructs.

      There is one case to be made for TDD though. When the designer writes the tests to be passed off to the implementer as part of the design. When, say, the implementation is being done off site.... But hardly anybody does that. They just have a programmer design, and implement both the tests and code from a basic set of specifications. And that's a plain waste of time. It's a round about way to 'hold people accountable for their code'... But accountability doesn't make bad programmers good, and it doesn't catch design bugs either.

    9. Re:If you did test-driven development by ahem · · Score: 1

      Um. Your first test case has incorrect delimiters -- {} vs (), or maybe everything after the first one is wrong. Maybe we should have done a code review?

      --
      Not A Sig
    10. Re:If you did test-driven development by Blakey+Rat · · Score: 1

      Not to mention that TDD is utterly useless for finding UI issues, assuming your code has a UI. There's no testing suite on earth that'll be able to tell you "the terminology on this button label is misleading."

      Now if you don't have a UI, maybe you don't care. But a significant amount of software does.

    11. Re:If you did test-driven development by Anonymous Coward · · Score: 0

      There is some overlap between the function of unit testing and of code review, but they are complementary. There are various kinds of bugs that are hard to catch by unit testing, but likely to be caught by someone reading the code and asking the right questions. It also helps ensure code quality - documentation, appropriate conventions, checking that no fragile hacks have been inserted into the code.

    12. Re:If you did test-driven development by Jane+Q.+Public · · Score: 1

      Well, actually, that's not true. You can do such tests with Selenium, or Hpricot, or Watir, for example. Each does it in a slightly different way.

    13. Re:If you did test-driven development by Blakey+Rat · · Score: 1

      Huh?

      The only thing I get from Googling those products is that they can be used to test web applications. Nothing about them being able to test that the label of a button is misleading-- I'm pretty confident in saying that that test will *never* be automated, at least not until we have A.I. that can think exactly like a human can.

      I think you were trying to respond to my other post on this topic, which does involve testing web apps. In which case: you may be right. Our company used JSUnit before we decided to just throw it out the window, because of code-bloat issues. We install our code on client websites, so we try to be as respectful as possible to their bandwidth. Since removing the test framework-related code, the obfuscated Javascript is literally half its former size, with more features.

    14. Re:If you did test-driven development by Jane+Q.+Public · · Score: 1

      I disagree. I just worked for a year (with a number of other progrmmers) on a complex social-networking web site. It is very complex and there are hundreds of thousands of lines of code.

      TDD actually saves time, because you don't have to go back and try to fix spaghetti code after you broke something. If something is broken, you know almost immediately. And if you are working with other coders, if somebody else breaks something of YOURS, then they (and you) also know, almost immediately.

      If bugs are getting through your testing at the same rate as your code without TDD (or even 1/10th as often), then you simply aren't testing right. That is inherent in the process.

      A "code review" on as complex a project as we were working on would be almost completely useless. You would never catch 90% of the bugs. QA would catch a bunch, of course, but then you are right back again to spending time tracking bugs and fixing them when they should not have been there in the first place.

      If you are doing TDD properly, your code will work first time, every time. If it doesn't, then somebody broke some tests and didn't fix them. Which was not allowed in our shop.

    15. Re:If you did test-driven development by heironymous · · Score: 1

      If TDD is taking you 200% longer, then frankly you were just skipping the testing.

    16. Re:If you did test-driven development by janwedekind · · Score: 1

      TDD can catch those fine, but so can a good code review.

      No. IMHO Test Driven Development is way better than code review. Code review requires human effort every time it is applied. Unit tests on the other hand can be performed by a computer whenever required. The reason why we are so entrenched into code reviews is that we are scared of unmaintainable and insufficiently documented code. However TDD provides a "safety-net" which gives you immediate feedback if you break the code while trying to fix design issues. Code review requires the team to have a complete understanding of the code and all possible inputs. TDD does not.

    17. Re:If you did test-driven development by Mr+Z · · Score: 1

      Most programmers outside Microsoft have thrown Hungarian notation out the window, [...]

      I can imagine the "type calculus" part of Hungarian notation being useful when writing large, complex programs in assembly code, such as much of the early Windows code, or with compilers and languages that don't take type-checking all that seriously (such as older C code). Now that type-checking compilers are widespread, encoding the type into the variable name is pretty much pointless. I don't need to know that piFoo is a pointer to int. If I use "Foo" in a manner inconsistent with pointer-to-int, enabling warnings in a modern C (or C++ or C# or Java or Pascal or.... (replacing 'pointer' with 'reference' as dictated by the language)) compiler will tell me. In other words, at least some aspects of Hungarian notation had their place as a reasonable convention for working around tool and language issues, and those aspects have just naturally gone obsolete. Your comment on VS C++ 3.0 nods towards this, I think, though I haven't ever used it, so I don't really know how good its type-checking and warnings were.

      That said, I'm all for having at least some general, broad conventions, such as using i, j, k for loop indices (and ii, jj, kk for sub-indices when 'tiling' loops), leaning toward "verb_object" types of names for functions that act on things, and so on. Likewise, I feel it's helpful to the readability of code to develop local conventions to domains of the code, perhaps in an ad hoc manner, to give a cohesive feel to the program.

      I'm talking about things such as common prefixes, or variables that are clearly related by how they're named. For example, I had a number of related parameters that controlled a particular algorithm I was tuning. You can probably see how they were related by how they were named:

      uint32_t hmod0, hmod1, hmod2, hmod3;

      uint32_t rotl0, rotl1, rotl2, rotl3;

      uint32_t coll0, coll1, coll2, coll3;

      (PS. If this comment shows up with funky vertical spacing, it's because I added extra <BR> tags to make the preview show up correctly, and even they don't seem to do anything. I don't know if the preview is accurate (unlikely) or b0rked (more likely), and I won't know until I hit ( _Submit_))

    18. Re:If you did test-driven development by Anonymous Coward · · Score: 0

      But the tests you think of doing in a test-first/test-driven environment are different to those you think of afterwards. Before you code, you are thinking about what the code should do. Afterwards, you are thinking about what the code does.

      Can you provide a reference to/summary of the story you mentioned?

    19. Re:If you did test-driven development by Your.Master · · Score: 1

      Yeah it is. It's an argument for methodologies that discourage the proliferation of sloppy code. It's not an argument for or against Test Driven Development, other than an argument against TDD being an panaccea, as you argued in the GGP post.

    20. Re:If you did test-driven development by ivan256 · · Score: 1

      However TDD provides a "safety-net" which gives you immediate feedback if you break the code while trying to fix design issues. Code review requires the team to have a complete understanding of the code and all possible inputs. TDD does not.

      You took my comment out of context. Either you're trying to mis-represent what I said, or you didn't understand it. Test driven development doesn't fix the "understanding all possible inputs" problem that you describe with code reviews. You still need to know, or your test will be faulty. In my experience with TDD, if your test fails because you made design changes (or bug fixes), more often than not you end up fixing the faulty assumptions or design decisions in your test, and not changing the code to pass the erroneous test.

    21. Re:If you did test-driven development by janwedekind · · Score: 1

      You took my comment out of context. Either you're trying to mis-represent what I said, or you didn't understand it.

      I didn't take your comment out of context. Indeed it would be very difficult to take your comment out of context since you claim that code review is better in almost every case.

      In my experience with TDD, if your test fails because you made design changes (or bug fixes), more often than not you end up fixing the faulty assumptions or design decisions in your test, and not changing the code to pass the erroneous test.

      Changing your assumptions while doing a code review can happen even more easily since you can do it without being aware of it. You can see unit tests as a way of formalising your assumptions and making them testable. I didn't say that the programmer doesn't need to understand what he/she is doing. What I am saying is that you don't have a complete understanding of your program all the time. Making your assumptions testable is a technical means to address this problem.

  18. accountability by dawilcox · · Score: 1

    Even if bugs are not found during code reviews, code reviews help the developers know that they are accountable for their code.

    1. Re:accountability by ivan256 · · Score: 1

      I just posted this above, but then I saw your comment.

      Accountability doesn't make bad programmers better. If you're in an organization that feels they need more accountability to increase quality, you should look up the chain for the problem. Question the hiring practices. Question the project planning... Those are the two places you're most likely to find the problem.

      Have you ever caught yourself reminding somebody how important something is in hopes of getting results more quickly? It's a typical tactic of an 'accountability' manager. If so, *you* are the problem. Either the developer isn't giving 100%, and needs a kick in the ass to stop slacking (why do you continue to employ them?), or you're pushing unreasonable expectations. Unreasonable expectations end in disappointment. Either you won't get what you wanted on time, or you'll get it at a lower quality level (costing more time down the road), or you'll lose your good developer to another company.

      Code reviews find bugs. They shouldn't find bugs every single time, 'cause you shouldn't be writing that many bugs. But they find bugs. That's all they should be used for.

  19. What is your historical programmer turnover rate? by G3ckoG33k · · Score: 1

    How many per cent of your programmers change, i.e. move to other companies, every year? The higher rate, the more need for well written, easy-to-read code.

  20. No doubt useful, but worth it...? by Derekloffin · · Score: 1

    I have no doubts at all that code reviews are highly useful. They can discover coding errors that are insanely hard to discover other ways. In anything that was critical, I would advocate them without the slightest hesitation. However, since this about non-critical stuff, then it is far more questionable. I think you should still use them, but on more limit basis. There will always be the tasks that are highly technical internally that need a good thorough looking through the code as well as UI test, but generally it becomes much less useful in more simplistic tasks, and UI testing will quite often (still not always, but most often) reveal the same errors. A good random inspection might be a decent replacement under these circumstances.

  21. yes! by piojo · · Score: 5, Insightful

    Well, my last workplace had code reviews for everything, and I found them tremendously helpful. They accomplish a few things:

    • catch basic errors (second set of eyes)
    • get new people up to speed (e.g., a more experienced dev says "actually, we have a library that would help here..."). Also, reviews can help an inexperienced engineer become a better developer.
    • keep employees abreast of new development (at least two people know about every commit in detail)

    Furthermore, if I edit code that was written by (or is owned by) Bill, I'll ask him to review it so he'll know about the new feature I added (which is good, if he ends up having to support it).

    --
    A cat can't teach a dog to bark.
  22. it always depends. by tempest69 · · Score: 1
    Depends on the team, project and needs.

    If you have padawan coders, or coders from another corporation.. code reviews matter.. stylistically they wont mesh, they may have some foreign habits that you need to either squash or embrace. These may be the people who do a C++ style for loop in perl when it is not appropriate. These may be best-practices nazis. These all warrant code review.

    If you are modifying byzantine code from the people who write HP office-jet software.. you need code review.

    If youre hooking up to an airplane or nuclear reactor.. you better know the answer.

    If you have grizzled coders who are stylistically homogenized, doing work that can have bugs... IE microsoft checkers (which allows you to change checkers in mid-double jump).. code review isnt so nessisary..

    Storm

  23. Code reviews no match for proper testing by Anonymous Coward · · Score: 0

    Code reviews are of limited use for finding errors, and are certainly no match for structured and comprehensive tests.

    Code reviews are one-shot, while properly written test-suites (on module, integration and system level) are repeatable. This means that you can easily run your test suites again when you change your code, but redoing the code reviews is too great a task. You simply can't re-review your code every time you make changes, but you CAN re-run properly automated test suites.

    Secondly, test suites are deterministic while code reviews aren't. With test suites you can be certain to catch all the error conditions you are testing for, whereas code reviews have random results, depending on the experience, capabilities and attention of the reviewers. You don't want your bug hunting to be non-deterministic

    Put your effort into proper testing, and use code reviews only when everything else fails, or in cases where they're used for enforcing coding guidelines or teaching people how the code works. Then once you got a proper test suite done, maintain it and expand it as you add code and functionality, and more importantly add new test cases every time you encounter a bug.

  24. Coding standards by readin · · Score: 4, Insightful
    The value of the code review depends on several factors, the most important being the coding standard against which the code is being reviewed. If the coding standard has a lot of hard and fast rules about what goes into the comment block, where variables should be declared, whether brackets go at the end of a line or on their own line, and how many returns a method can have, then the code review will be mostly about religious issues and petty formatting. On the other hand, a coding standard with many "should"s instead of "shall"s that allow the developer, combined with reviewers and especially review moderators who know what is important can what isn't, can make code reviews very useful, especially early in a project and especially with junior developers.

    A code review is unlikely to uncover many errors. Most code is just too complex for another developer to spot errors. Unit testing is much better at that. What a code review can do is
    • 1. Coach new developers by helping them learn and/or remember best practices: "Please use "literal".equals(variable) rather than variable.equals("literal"), just in case the variable is null."
    • 2. Remind people to follow the important standards, or recognize that you're missing important standards and need to set one: If your DAO "find" method doesn't find the expected record, do you return null or do you throw an exception? Both have strengths, but everyone on the projct should be doing it the same way. Code reviews will help uncover discrepancies.
    • 3. Uncover future maintenance issues. The code may be too complex for reviewers to find bugs during the review, but they should at least be able to follow what the code is doing. If they can't, the code either needs restructuring or better commenting.
    --
    I often don't like the choices people make, but I like the fact that people make choices. That's why I'm a conservative.
    1. Re:Coding standards by erikharrison · · Score: 1

      In my experience code reviews trap errors all the time. Second sets of eyes catch stuff like "You forgot to set the status property there" or "that's an off by one error in that loop".

      Most commercial code is written with an iterative design/implement cycle. This causes code paths to grow rapidly. A programmer writing the code is constantly updating his mental model of all code paths. A developer coming in on feature complete code has to build his mental model from scratch - he's going to catch code paths and exceptional cases that grew up in development.

      In my experience, a solid, robust test suite can automate the edit/run/check cycle while in development, and is great at catching regressions in the future. But short of true waterfall development, where you have an exceptionally rigid spec, it's really really tough to make sure you're test suite catches every code path - especially since modern dev practices (objects/exceptions) create implicit rather than implicit routes through your code.

      This is my experience, however. Maybe I'm not working at a high end enough shop that every dev is unlikely to make these kinds of basic-but-potentially-shippable errors. But that's the beauty of a well thought out dev process - those of us less talented can be more likely to produce something of quality.

    2. Re:Coding standards by readin · · Score: 1

      This is my experience, however. Maybe I'm not working at a high end enough shop that every dev is unlikely to make these kinds of basic-but-potentially-shippable errors. But that's the beauty of a well thought out dev process - those of us less talented can be more likely to produce something of quality.

      Or perhaps you're not working for a shop where the customer is not willing to pay for perfect code and you have to make reasonable trade-offs between expensive reviews of everything and the risk of shipping a bug or two.

      For a code review to pick up on the trickier defects, the reviewers would need to spend a lot of time with the code - time that could otherwise be spent on new features, or time that simply won't have to be charged to the customer and helping the customer stay in business with low costs. A bug might cost them something, but it likely won't cost them as much as a code review. A code review can certainly catch defects that otherwise escape into production, but it is one of the more expensive ways to catch bugs. The original poster said "our code is intended for desktop, non-critical use". In other words, it doesn't need to be perfect. It needs to be pretty good and affordable. As developers, we may prefer perfect over pretty good, but Microsoft isn't showing any signs of going bankrupt.

      --
      I often don't like the choices people make, but I like the fact that people make choices. That's why I'm a conservative.
    3. Re:Coding standards by aug24 · · Score: 1

      I'm curious (and don't want to start a war on something so trivial) but what strengths are there for return null?

      --
      You're only jealous cos the little penguins are talking to me.
    4. Re:Coding standards by readin · · Score: 1

      I'm curious (and don't want to start a war on something so trivial) but what strengths are there for return null?

      • Theory: Exceptions are for exceptional conditions (because of the implied goto they carry). They shouldn't be used for run-of-the-mill occurrances such as not finding a record isn't always expected to exist.
      • Practical: I may be wrong on this, but I've heard that try-catch is expensive in Java due to the stack tracing.
      --
      I often don't like the choices people make, but I like the fact that people make choices. That's why I'm a conservative.
  25. Yes they are worth it by DrXym · · Score: 1
    I've led large teams of developers and I guarantee that even if you write coding standards, or have a common coding style for the project that somebody in your team will either ignore it, or do their own thing. The guidelines might say don't use hungarian but somebody still will. Code reviews are an excellent way to enforce standards and ensure a base level of code quality across the board. Aside from general style, reviews mean you catch people not programming defensively, not catching exceptions, not writing readable code, not logging, using weird notation, weird indentation and so on. After getting drubbed a few times in reviews most programmers are a lot more conscious of the way they write code and the overall standard is raised. After that reviews are still a useful practice because I've lost count of the number of potential bugs they've caught.

    Now maybe there are reasons that reviews should be conducted in one way or another. My preference is formal group reviews for brand new code pr new team developers and over-the-shoulder reviews for substantial checkins thereafter. Between the two I guarantee you save more time than if the bugs went in and were only uncovered later in QA or worse, in production.

  26. they are worth it by acidrain · · Score: 5, Insightful

    no

    You often *have* to review a entry level programmer's work until it reaches an acceptable quality. I consider code reviews as a method of improving the programmer more so than the code. One an engineer is producing generally acceptable code it becomes safe enough to treat their code as a black box and wait for problems to be unearthed by testing. If you are shipping bugs your problem is testing, not code reviews. Finally, the cheapest way to do code reviews is for a manager to just scan submitted code from time to time and send out polite emails if they see something amiss. On the other hand getting five senior guys in a room to discuss the work of another senior engineer is a just going to result in unproductive, cranky engineers.

    --
    -- http://thegirlorthecar.com funny dating game for guys
  27. Worth It But... by EXTomar · · Score: 1

    Code reviews are worth it but often the "cost" of doing proper reviews are underestimated. To implement results of the review may cost a bit of time and money if not another review where if project managers and planners just assume its a "fast fix" then problems will arrise.

  28. Practical Programmer: Inspections by chrisreedy · · Score: 1

    You should check out this reference: (Apologies, you need access to the ACM Library to read the article) http://portal.acm.org/citation.cfm?id=299161. Robert Glass discusses this exact issue. The article offers some references to research done using alternative approaches to inspections.

    1. Re:Practical Programmer: Inspections by Timothy+Brownawell · · Score: 1

      You should check out this reference: (Apologies, you need access to the ACM Library to read the article) http://portal.acm.org/citation.cfm?id=299161. Robert Glass discusses this exact issue. The article offers some references to research done using alternative approaches to inspections.

      Non-paywall link: http://faculty.fortlewis.edu/ADAMS_E/CLASSES/CS370SWENGRII/WebWinter04/NOTES/Glassinspectionarticle.pdf

  29. Re:Hell Fucking No by Anonymous Coward · · Score: 0, Offtopic

    I don't know why the parent is modded "troll", he's 100 percent correct. And they get curry EVERYWHERE between the 1's and 0's, it's just a mess.

  30. It's vital by Comatose51 · · Score: 1

    For a project that's more than one or two people, code reviews are vital. They enforce consistency in style and methodology. They also spread knowledge. They mitigate the "bus factor" (how negatively impacted your project will be if someone is hit by a bus). I've worked professionally at two companies. One of them did not have code reviews. Every time someone left the company, the project either grinds to a halt or they have to rewrite that person's work because no one else can understand it. There were a ton of rewrites. At my current company, we use Review Board (open source, built on Django) to do code reviews. People don't leave often but they do transfer around the team to work on different sections. That's rarely ever an issue because the code is understandable by all of us. I work in both the UI and the middle layer with business logic and occasionally DB related code. I can move between the three because the consistency that exists. When I move into a new section, I do make mistakes but those mistakes are caught during code review and I learn.

    --
    EvilCON - Made Famous by /.
  31. Delusions of grandeur by Anonymous Coward · · Score: 5, Insightful

    My working life has been spent in projects developed by individuals or small teams (less than six programmers). I would describe my working environments as "CMM level 1 and damn proud of it." The teams I have been on have been consistently successful without having a consistent methodology. The success is the result of having a bunch of competent people who respect each other, and are motivated by the idea of producing something that customers will pay money for, because it works. And by the knowledge that they'll stick with the project for a while, and if they make any messes they'll be the same people who have to clean them up later.

    I've suffered throughout my working life from inexperienced managers and programmers who suffer from what I call delusions of grandeur. 90% of the stuff that people learn about project management seems to me to be intended for use in projects with fifty programmers or more. Projects where the manager can't get a grasp of the project by walking around and schmoozing with people. Projects that are big enough that there are constantly people leaving and joining them. I don't know about projects like that. I'm inclined to think that formal management processes may be useful, even essential there.

    But on small-team projects, it just gets in the way.

    The problem is that the books that explain the capital-M Methodologies and the code review process and so forth never say, in so many words, that these are management procedures for projects with more than fifty people. They just say, "this is how you do it." And people come out of courses believing that "doing it right" means applying all this stuff. And that anything else is unprofessional.

    The hidden assumption is that everyone wants to follow a career path where they manage more and more and more people on bigger and bigger and bigger projects and make more and more and more money. When I worked at a Fortune 500 company, people were very frank about it. It was a waste of time proposing or working on small stuff. You had to "think big" or management would never take any interest in what you were doing.

    Well, I'm here to say that if you want to think big and manage like the big boys do, fine. But don't try it on a small-team project where the team members have gelled into a coherent unit, and know each other and work well together, and plan to stick around for a while.

    Code reviews? Gimme a break. In the natural course of events, other team members are going to have to work with my code. If I don't care about what they think about it _when they're editing it to get their job done,_ I'm sure not going to care what they think about it in some room with a whiteboard. And we're effectively eviewing each others' code in the natural course of getting our jobs done, then sealing ourselves into a room with a whiteboard and no debugger, isn't going to be any better than what we naturally do without any formal process.

    1. Re:Delusions of grandeur by im_thatoneguy · · Score: 1

      The counter point is where I work. We're all artists. And it used to be that only 2 of us really knew anything about programming. Between the two of us. Even though we sit next to each other-- we still would write redundant code unaware of what the other already had. We don't do 'code reviews' but we often read each other's code to see how they approached something and if they had a better solution.

      As it is we accidentally discover the other has written a new library for something that already exists when looking for something unrelated. "Wow you already wrote an XYZ function for ... I really wish I knew that yesterday when I spent 2 hours working on that"

      So even on a scale of 2 I can see the value in everyone being aware of what's out there. Maybe not a thorough review but certainly an overview of what others have done recently.

    2. Re:Delusions of grandeur by Anonymous Coward · · Score: 0

      I'm with you, low ceremony, one reviewer usually chosen by the programmer (but has to be someone who is technically qualified). I've seen that work in a cost effective way. If a programmer/reviewer team makes a habit of checking in buggy code, then the manager should step in and assign a reviewer for that guy's code, at the minimum.

      This tends to avoid a lot of the politics and grandstanding that often creep up in these situations, which can be an incredible waste of time. When there are multiple reviewers and/or code reviews are posted online, some team members (new and old) will be hankering to show off and will raise picayune objections.

    3. Re:Delusions of grandeur by Anonymous Coward · · Score: 0

      My working life has been spent in projects developed by individuals or small teams (less than six programmers). I would describe my working environments as "CMM level 1 and damn proud of it." The teams I have been on have been consistently successful without having a consistent methodology. The success is the result of having a bunch of competent people who respect each other, and are motivated by the idea of producing something that customers will pay money for, because it works. And by the knowledge that they'll stick with the project for a while, and if they make any messes they'll be the same people who have to clean them up later.

      I've suffered throughout my working life from inexperienced managers and programmers who suffer from what I call delusions of grandeur. 90% of the stuff that people learn about project management seems to me to be intended for use in projects with fifty programmers or more. Projects where the manager can't get a grasp of the project by walking around and schmoozing with people. Projects that are big enough that there are constantly people leaving and joining them. I don't know about projects like that. I'm inclined to think that formal management processes may be useful, even essential there.

      But on small-team projects, it just gets in the way.

      The problem is that the books that explain the capital-M Methodologies and the code review process and so forth never say, in so many words, that these are management procedures for projects with more than fifty people. They just say, "this is how you do it." And people come out of courses believing that "doing it right" means applying all this stuff. And that anything else is unprofessional.

      The hidden assumption is that everyone wants to follow a career path where they manage more and more and more people on bigger and bigger and bigger projects and make more and more and more money. When I worked at a Fortune 500 company, people were very frank about it. It was a waste of time proposing or working on small stuff. You had to "think big" or management would never take any interest in what you were doing.

      Well, I'm here to say that if you want to think big and manage like the big boys do, fine. But don't try it on a small-team project where the team members have gelled into a coherent unit, and know each other and work well together, and plan to stick around for a while.

      Code reviews? Gimme a break. In the natural course of events, other team members are going to have to work with my code. If I don't care about what they think about it _when they're editing it to get their job done,_ I'm sure not going to care what they think about it in some room with a whiteboard. And we're effectively eviewing each others' code in the natural course of getting our jobs done, then sealing ourselves into a room with a whiteboard and no debugger, isn't going to be any better than what we naturally do without any formal process.

      It's been my experience that delusions of grandeur occur far more frequently at CMM level 1 (Ad hoc (Chaotic)). It is generally found in individual projects or small teams where 1 (or a very few developers) have had some level of success and this has lead them to believe that they can "wing it" through just about any project. That works fine, until they are wrong.

      By definition (CCM 1), their processes aren't repeatable, they aren't defined and documented, and they don't adapt well to other projects and processes without tremendous effort. So when one of them gets hit by a bus, decides to let his ego halt a project, or encounters projects requiring outside expertise, the projects fail catastrophically. Almost invariably, CMM level 1 folks will blame managers that 'just don't understand', customers that are 'idiots', and other coders that are 'incompetent'. The truth is, there are very small projects and/or short term projects where CMM level 1 works great. But if you NEED your project to stick around (longevity), to be able to be picked up by others (turnover), and

    4. Re:Delusions of grandeur by khallow · · Score: 1

      I'm leery of both sides of the argument here. Formalizing your processes doesn't imply to me that those processes have improved at all. At the same time, even a small team can hurt itself with bad communication.

    5. Re:Delusions of grandeur by cryptoluddite · · Score: 1

      Code reviews are like testing... it's only worth doing if the quality is already high. A tester that ever has to file a bug like "crashes if run with zero args, or 5 or more args" is going to shoot somebody or just phone it in. Same with code reviews. If you have to explain to somebody why their use of a bubble sort is "not a good solution" then there is no point in doing one in the first place. It's just wasting people's time.

      But on the other hand if you go to a code review and see some code implementing chmod octal and oug+-rwx,... syntax in 40 lines compiling to ~200 bytes of assembly you're going to say 'damn, that's cool' and it'll pump everybody up and they might learn a few things about binary operations and masks. You might catch some errors too, that's nice, but the main point of the review should be to learn about the code and to learn better programming. If you want to use them to catch errors, you should use testing and auditing of the code instead (if the presence of a bug is important enough to convene a meeting to look the for the mere possibility of it existing, then you need to really get serious about it).

    6. Re:Delusions of grandeur by alephnull42 · · Score: 1

      The problems you describe under "capital-M Methodologies" sound similar to "Cargo Cult Software Engineering" http://stevemcconnell.com/ieeesoftware/eic10.htm

      --
      Not confused enough? http://translate.google.com/translate?u=www.slashdot.jp&hl=en&ie=UTF8&sl=ja&tl=en
  32. Depends what you are reviewing by grahamsz · · Score: 4, Insightful

    Quite simply, code reviews cost money and production bugs cost money.

    We do code reviews for anything where it'll either be devastating expensive if we encounter a failure or if it'll be very hard to detect a failure. Otherwise, in my particular line of work, it's more economical to accept a lower cost and faster pace of development at the expense of dealing with a few bugs that are discovered in production.

    1. Re:Depends what you are reviewing by DrLang21 · · Score: 2, Interesting

      This is the most reasoned response. I would think that, like validation, code review activities should be appropriate to the level of risk involved. I also believe that good reviews, be it design, code, or documentation, should be kept on the topic of acceptability, not perfection. Code can very easily suffer from the word-smithing problem. If you start talking about a problem in code that really does not have a significant impact on quality, it's time to move to the next item. This is easier said than done however.

      --
      I see the glass as full with a FoS of 2.
    2. Re:Depends what you are reviewing by Anonymous Coward · · Score: 0

      Except that development costs are only 10% of the costs of that code. The other 90% is maintenance. Code that's been reviewed has had other developers look at it and agree that the implementation is not only correct, but it's understandable and maintainable.

    3. Re:Depends what you are reviewing by Anonymous Coward · · Score: 0

      no, that's not ok! As is not ok to buy a car with wheels falling off or having a surgery and the surgeon forgetting something inside you. So why should it be ok to have software full of bugs? I don't understand...

      Use code reviews or whatever works for you. For me is TDD and pairing but we have to start raising the bar of the software quality of our industry.

    4. Re:Depends what you are reviewing by grahamsz · · Score: 1

      But it depends what you are reviewing.

      I run a discussion site that's not too different from slashdot. I code parts of that drunk off my ass on a live production server. If i fuck something up and can't fix it until the morning then it's really not that big of a deal.

      When i'm writing code that handles million dollar invoices for a customer then of course it gets thoroughly reviewed and often pair-programmed.

      There's some middle ground there. Code reviews DONT catch all bugs, no matter how well you do them. It's a process that costs money and improves quality - it's not magic.

    5. Re:Depends what you are reviewing by Anonymous Coward · · Score: 0

      Quite simply, code reviews cost money and production bugs cost money.

      We do code reviews for anything where it'll either be devastating expensive if we encounter a failure or if it'll be very hard to detect a failure. Otherwise, in my particular line of work, it's more economical to accept a lower cost and faster pace of development at the expense of dealing with a few bugs that are discovered in production.

      Yes, but code refactoring also costs money. If someone has to come back later to add functionality, but they can't figure out what is going on, it's a problem.

  33. Video on Code Review by Anonymous Coward · · Score: 0

    Code review is often viewed as a compliance task, not productive. This video talks about what code review can be, and how to make it more effective.

    Code Reviews

  34. Figure out how much just one bug costs.... by Anonymous Coward · · Score: 0

    The simplest bug found post-ship is a helluva lot more than the most expensive code review you could ever have nightmares about. So probably just every second or third code review (or maybe even less...) has to catch just ONE simple bug for all code reviews to be cost effective. In other words, if two out of three code reviews are totally clean and the third finds just one bug, you're AHEAD in cost. And we all know code reviews catch a helluva lot more than just one simple bug each.

    Also, code reviews prevent programmers from deliberately writing obfuscated code. FWIW, if you work for me and I catch you deliberately obfuscating code, you're on your way out. Period. It may take me a while, but you're gonna be GONE before long.

  35. Doesn't mean it was a value add. by Anonymous Coward · · Score: 0

    Yes- but would the time have been better spent on something else than an absolutely corner-case bug. That's the question. Not whether they can catch bugs... They can! But can you catch more with those same resources spent on UI testing, or writing automated tests. Or is the business better off accepting that little bug and spending the time developing new work. Just because a bug was found doesn't mean the exercise was valuable.

    1. Re:Doesn't mean it was a value add. by Omnifarious · · Score: 1

      Well, that particular bug would've cropped up randomly, literally. It would've been extremely vexing and totally unacceptable. And it would definitely have bit people. And not just people who performed a certain set of actions. It would've bitten anybody who used a default-on feature at random but rare intervals.

  36. "Take forever" by shutdown+-p+now · · Score: 3, Insightful

    What we've found is that code reviews take forever ...

    In one place where I worked in the past, we had a very simple rule: if you are doing a code review, and it takes longer than 10 minutes, then you stop it right there and return the whole thing marked as "overcomplicated" - if it really takes that long, then either the code is written in non-obvious ways and/or poorly commented (which will result in poor maintainability anyway), or the change is too big for one source control commit. By and large, it worked, even if you have to make exceptions occasionally (but at that point you know it's not a typical review, and pay more attention).

    In addition to that, you might want to consider better tooling. If you're doing reviews by sending .diff files over email, you're doing it wrong - there are many specialized tools out there that will do automatic and smart diffing (including between rounds in a multi-round CR), notify people responsible for affected files, allow to set up the workflow according to your needs, enable attaching review comments and conversations to particular files and lines of code, and so on. The shop I was working for used Code Collaborator , and I found it to be pretty good, but there are plenty other similar tools out there, and you might even be able to find some good free ones.

    1. Re:"Take forever" by jgrahn · · Score: 1

      In addition to that, you might want to consider better tooling. If you're doing reviews by sending .diff files over email, you're doing it wrong - there are many specialized tools out there that will do automatic and smart diffing (including between rounds in a multi-round CR), notify people responsible for affected files, allow to set up the workflow according to your needs, enable attaching review comments and conversations to particular files and lines of code, and so on.

      Do people really send patches around for review? I distrust fancy collaboration tools. All you need is the label/tag in the version control system and everything is there: the actual code and other files (e.g. user documentation) to review, and the checkin comments leading up to it.

      Maybe the review comments should also go into version control, so what you eventually merge is (a) the code under review + (b) review comments pointing out what sucks + (c) the changes which eliminate the review comments and the (if the comments where valid) things they complained about.

    2. Re:"Take forever" by Anonymous Coward · · Score: 0

      I've used that same tool, and it provides a lot you can't get from a tag. You should give the tools another shot.

  37. Yes by phil_at_. · · Score: 1

    You may not "see" it in the sense of fixing UI bugs, but in the long run it saves you TONS of time. It ensures people code to an internal coding style document (you have one, right??) which makes code more readable and maintainable in the long run. It also, of course, can catch subtle bugs that may be compounded in time with new features. Together these saves tons of money and time in the long run. Don't be short-sighted.

  38. Code Reviews for the lulz by CuteSteveJobs · · Score: 2, Interesting

    When I was working as a trainee, I was invited to the code review of a mediocre programmer. A bunch of people were there including a senior A/P who was my boss. My boss started ripping into it and I quickly realized the mediocre programmer - who couldn't code his way out of a wet paper bag - had taken one of my programs and tried changing it (including my name). It didn't work and the senior A/P was asking him 'WTF does this do?'

    Oh the dilemma. Do I take ownership and defend "my" code, or say nothing and enjoy watching him squirm? I did the latter watching him go "ummmmm ummmmm ummmmm". Finally medicore programmer admitted he copied it and it was really mine. I said "Well it was working when you copied it off me."

    Needless to say he ended up being promoted to manager. Not even a PHB which requires a bit of cunning, he was just a flat out idiot. I keep in touch with some of my coworkers to this day and whenever we want to describe a certain type of idiot we use his name. Duuuuuuuuuuuuuuh.

    1. Re:Code Reviews for the lulz by timmarhy · · Score: 1

      it's hard to believe anyone doesn't think code reviews are worthwhile. without them all it takes is one retard to destroy a company.

      --
      If you mod me down, I will become more powerful than you can imagine....
    2. Re:Code Reviews for the lulz by murdocj · · Score: 1

      It really depends on the situation. I worked for many years at a small, company that grew relatively slowly where all of the developers were fairly senior. We all had experience, we had been at the same company for a while, and it was pretty clear that none of us was doofus. We did end up with some different coding styles but we all wrote relatively clean code and it wasn't a big deal to glance at someone else's code.

      Not to mention that since the company treated us as human beings and not as replaceable units, people stayed around. It's not a big deal to handle turnover if you're only losing a person ever few years. As a contrast, when we were bought out, the new parent company treated people like crap, and their turnover was unbelievable, something like a couple of programmers a month.

      Basically we had what is sometimes called "weak code ownership" where it was clear that each module was "owned" by one or two people, but anyone was free to examine the code, or even modify the code if they discussed the changes with the owner. It's a really pleasant and productive way to work, and I highly recommend it, if you can find the right company.

    3. Re:Code Reviews for the lulz by jgrahn · · Score: 1

      Basically we had what is sometimes called "weak code ownership" where it was clear that each module was "owned" by one or two people, but anyone was free to examine the code, or even modify the code if they discussed the changes with the owner. It's a really pleasant and productive way to work, and I highly recommend it, if you can find the right company.

      That paragraph scares me, because you suggest that there are workplaces where you're *not* supposed to look at anyone else's code. That would be a really stupid system.

      In my experience, it's usually the "guest" (myself included) who is too reluctant to read it.

    4. Re:Code Reviews for the lulz by murdocj · · Score: 1

      That paragraph scares me, because you suggest that there are workplaces where you're *not* supposed to look at anyone else's code. That would be a really stupid system.

      It is scary, because there are some programmers who are so "brilliant" that they don't want anyone examining / modifying their "perfect" code. Fortunately the company I worked for tended to weed out such geniuses.

      I'm basing the term "weak code ownership" on article I read a few years back where the author outlined a couple of models, stretching from strong code ownership ("it's my code, no one else touch it") down to group code ownership ("we all own the code"). I personally have found the weak code ownership model the most productive and satisfying... you always have someone who is ultimately responsible for the state of the code, but you also have multiple developers modifying / examining code as necessary.

  39. I think it's worked well. by dgcaste · · Score: 1

    Our shareholders do our code reviews.

    Steve B.

  40. Yes and no. by ThePhilips · · Score: 1

    In my experience, code reviews are generally useless. Main problem is that very few software projects have decent documentation which can be used as base for code review. Without documentation, reviews generally end up being a R&D-wide (or worse) squabble.

    As development manager, one should try to make the reviews an integral part of development process. Keyword is "integral." Results of review are hard to quantify, thus something should be done to make them useful to the other phases of development process. IOW, results of reviews shouldn't be something on their own, they should be used somewhere too.

    One major use for code reviews is when their results are fed back into testing effort. There are companies which test software based solely on high level list of features. I witnessed at least once quite huge mess, caused by bogus design done by R&D: essentially trivial global option was switching code in several programs to alternative code paths. R&D on tight schedule to implement the option simply copy-pasted with minor modifications piles of code. Test department obviously had no idea about that and the option wasn't even properly documented. Code review might have discovered that sooner (e.g. before we actually had several customers attempting to deploy the feature), pushing R&D to do proper design w/o code duplication (unrealistic for commercially developed software) or at least feeding the finding to test department so that they could have tested the whole system twice (option is on, options is off).

    Our code is intended for desktop, non-critical use, so I asked my boss to consider whether it was worth spending so much time on examining built code, given our experience not getting much out of it.

    No results from core review is a positive result.

    But there is a gotcha: if all your developers have similar/save background, then efficiency of code review would be extremely low as such developers tend to do same mistakes. For effective code review, you need people who view the software differently: e.g. developers of one component review another component. Best of all if they would also have different education and background.

    But obviously developers themselves should be willing to participate in code reviews. Code review is quite exhausting (e.g. I can review only about 3.5K LOC per day - more my brains do not manage) and poorly motivated developers would do very sloppy job at that. If you can show developers with some graphs from issue tracking system that code review improves quality, then they might be more interested in the process. Yet, still, do not expect any miracles.

    Honestly though code review was always my dream. As developer I do quite a number of trivial coding mistakes. When possible I adjust my coding style so that compilers can detect such errors, but commercial compilers I have to use are quite moronic (compared to GCC) when it comes to warnings. And not on one project I had seen people disabling compiler warnings altogether because ... because ... like hell I know what goes in heads of generic developers on pay roll.

    --
    All hope abandon ye who enter here.
  41. Science by felix+rayman · · Score: 1

    This has been studied extensively. Peer review of code is much better at finding bugs than QA testing.

    If you release code without QA testing and the process works for you, fine, you can consider releasing code without peer review.

    If you wouldn't consider releasing code without testing, but currently release it without peer review, you are batshit insane. Sucks to be you. Sucks even more to be your support department.

  42. We do this. It's valuable. by erikharrison · · Score: 1

    In my shop, there is no formal code review process. But informally, we all have to maintain this stuff, and there aren't enough of us that everyone gets one nice, clearly demarcated area of responsibility. So in that principle, there is a strong informal process.

    In the course of designing a piece of software, or subsystem there is a lot of "Okay, here is my approach. See any pitfalls?" During implementation, there is a lot of over the shoulder "could you take this over?". And once a piece of code is ready to be merged into trunk, a fresh pair of eyes are pulled over, and the code is looked over.

    It's a lightweight process, code gets checked numerous times, and we don't run into cases where you suddenly have to review several thousands of lines of code. This has caught numerous bugs, time and time again, and catches the kinds of bugs that user level testing can be the worst at finding - corner cases and intermittent issues.

  43. Definitely yes by oblivious · · Score: 1

    Code reviews are worth it, you just need to figure out how to do them so they aren't a pain and are useful. Keep in mind that pair programming is continuous code review, and is a good thing if at least one of the pair is a senior developer. The formal, get in a room, and review all the code since X is a waste of time. My team is fairly small, I have two scrum teams of 5 developers each. For code review, we have version control set up to mail all commit summaries to everyone on the team. One of the duties of the scrum master is to review all commit summaries from both teams, and bring up any problems with the team member. This is generally just a forward of the commit summary to the appropriate developer with comments in the email, and cc to the team. I found this works extremely well and does not interrupt the work flow at all.

  44. They can be valuable by realnrh · · Score: 1

    It depends entirely on what your purpose for them is. You should have a good test suite that passes, good coverage, and have done some over-the-shoulder checks. Then the formal code review can be less about "Let's find bugs" as it is a style check and a chance for everyone else (who might get called upon to support the system later) to understand the general purpose, operation, and any clever bits. If your code review is supposed to be the bug hunt, then yeah, that's not efficient.

    --
    Long? What do you mean the signature at the bottom of every comment I post on Slashdot is too lo
  45. depends by oee · · Score: 1

    Code reviews

    if an expert:
          if humble: definitely worth it.
          if arrogant: a pain, but probably worth it
    else if your boss (but not an expert)
          if nice: alright.
          if a jerk: a nightmare (lobby against reviews)
    else
          not worth it (lobby against reviews)
    end

  46. If you're asking, then you're doing it wrong. by asmdsr · · Score: 1

    There's two aspects to make it work:

    - Tools. You should put some effort into your tools. The features to aspire to are:
        - tight VCS integration
        - email integration
        - visual diff viewer
        - inline comment annotations
        - web interface is preferable

    - Policy.
        - Every change should be individually reviewed, before it is committed (reviewer(s) give the final OK).
        - Smaller changes should be encouraged. The smaller the better, but more than 1000 lines is too big. Reviewers should request large changes to be broken up if necessary.
        - A single reviewer per change is adequate, on average. 2-3 is also common.
        - Reviews should also be cc'd to team and other stakeholders; unsolicited reviews/comments should be encouraged.
        - A consistent code style should be enforced in reviews.

    The attitude of the engineers is important, but difficult to enact. It's particularly hard when you're bootstrapping a new policy like this into your engineering culture. Although the reviewer has the final say, in reality they don't have any real power over their colleagues' actions. So they should focus on constructive, concrete issues and back off once a reasonable debate has occurred. Design reviews are important because if design issues come up in code reviews it can get ugly.

  47. Code reviews are manager fodder by EmperorOfCanada · · Score: 1

    Personally I am a unit test after coding person. This tends to result in a code review by default. Bad code would have trouble getting past this point in the process.

    1. Re:Code reviews are manager fodder by fooslacker · · Score: 1

      Write your unit test first and do automated unit testing and you'll find even more benefit. That said, unit testing and code reviews have different aims. Code reviews address non-functional, style, and supportability issues not functional bug issues. In general your post is correct in stating that unit testing of more benefit than code reviews but that is because the problem unit testing addresses is more damaging not because unit testing and code reviews address the same thing and one is more effective. If your organization is using code reviews to address functional bugs then yes it's just management fodder, if they use them correctly then it can provide actual benefit depending on the organization and situation.

    2. Re:Code reviews are manager fodder by ivan256 · · Score: 1

      I work on a small team (20 developers). Every day I see at least one bug in highly unit tested code that wouldn't have made it past a code review.

      Unit tests are a situationally appropriate tool. But they are not a replacement for a review on any team larger than a few people. You have to understand every possible interaction between what you're changing and the rest of the system to write a 100% effective unit test. That just can't happen once you have a few dozen people writing your product.

    3. Re:Code reviews are manager fodder by fooslacker · · Score: 1

      You have to understand every possible interaction between what you're changing and the rest of the system to write a 100% effective unit test. That just can't happen once you have a few dozen people writing your product.

      This is what regression tests are for, not unit tests. Also while a code review might catch this but it's not a guarantee and it's an incredibly expensive option when automated regression testing is much more effective. Code reviews really aren't for bug reduction and they are a poor tool for it. It's kinda like using a hammer to cut metal. It's not that it can't be effective it's just that it's not the best or even a good way to address that particular task.

    4. Re:Code reviews are manager fodder by fooslacker · · Score: 1

      Just to be clear (I don't want folks to think I'm anti-code review) code reviews do serve an important purpose regarding style consistency, and supportability, they just don't do much good for bug fixing...or at least they are a poor tool for it.

      They can also be effective in finding best-practice issues around NFRs such as performance if your shop lacks a disciplined NFR testing approach as many do, though I'd argue that there are better tools and processes for this too and your shop would benefit more from investing in them.

  48. a fucktonne? by grahamsz · · Score: 4, Funny

    Damn europeans and their metric system.

    How many shitloads are in a fucktonne?

    1. Re:a fucktonne? by Anrego · · Score: 1

      I happen to be Canadian you insensitive clod!

    2. Re:a fucktonne? by Anonymous Coward · · Score: 0

      Actually it is a little more universal than that. The imperial system is in the minority now.

    3. Re:a fucktonne? by bosef1 · · Score: 1

      Unfortunately, the shitload-to-fucktonne conversion depends on the Savage-Santorum thrust/gauge coefficient matrix, which of course varies with load, oscillatory frequency, girth, and country of origin. For toy problems with minimal covariance, you can handle the second-order "fatty" effects using a first order "Vespa" approximation; but in general the only way to determine the matrix values is by empirical measurement. :-(

      It may be noted that the butt-load, or pipe, is equalivalent to two hogsheads, which is 2x63=126 US gallons (108 Imperial accounting for the differences in volume and the size of the hogshead).

    4. Re:a fucktonne? by Anonymous Coward · · Score: 0

      1000

    5. Re:a fucktonne? by jhd · · Score: 2, Funny

      How many shitloads are in a fucktonne?

      Wolfram Alpha knows ;-)

    6. Re:a fucktonne? by TheSam · · Score: 0

      Damn europeans and their metric system.

      How many shitloads are in a fucktonne?

      42, duh

    7. Re:a fucktonne? by alephnull42 · · Score: 1

      >>How many shitloads are in a fucktonne?
      It depends:
      - British or American shitload?
      - Land or nautical fucktonne?

      --
      Not confused enough? http://translate.google.com/translate?u=www.slashdot.jp&hl=en&ie=UTF8&sl=ja&tl=en
    8. Re:a fucktonne? by fatboy · · Score: 1

      Depends on if we are talking about imperial shitloads or not.

      --
      --fatboy
    9. Re:a fucktonne? by Anonymous Coward · · Score: 0

      Damn europeans and their metric system.

      lol heads up dude. its like everyone BUT the US and their metric system.

    10. Re:a fucktonne? by dstones · · Score: 1

      Damn europeans and their metric system.

      lol heads up dude. its about everyone BUT the US that uses the metric system.

    11. Re:a fucktonne? by grahamsz · · Score: 1

      I was being sarcastic (like us europeans often are)

  49. An Argument? by Swanktastic · · Score: 1

    If you actually got into an argument with your boss, then I'm guessing you went about things all wrong in trying to make your point. Some tips of advice for advocating a change of procedure:

    1) Don't make this case in front of other people. This has to be behind closed doors. If you bring up something in front of others, it simply looks like you're trying to make the boss look like a bad guy to everyone else, and he/she will get defensive.

    2) The easiest job in the world is to be a critic. If you come up with a well reasoned plan, with statistics, etc. that prove your point and propose a new methodology, you're well on your way to getting your way. Half the time subordinates pose a problem to me, they're simply dumping more work on my lap. I try to be reasonable, but it's a heck of a lot easier to approve something if there's a reasonable proposal to work with. Especially if the proposal looks to have a low risk and substantial gain. Not everyone wants to stake their reputation on certain projects.

    3) The problem may/may not lie with your boss. He/she may have had this exact discussion with his/her boss and already been shot down.

    4) You have to be genuinely motivated to improve your work product. The motivation cannot be "code reviews are a waste of time." If you pose something that way, you're essentially calling your boss an idiot for asking you to do them. Also, your boss is immediately going to be suspicious you're simply trying to reduce your responsibilities.

    5) If that fails, you may as well embrace the reviews and dedicate your time to improving the way they are conducted. Spend some time researching what works and what doesn't. Then go to your boss and ask permission to implement some of the best practices. Managers get irritated when people expect them to solve all their problems. Do your best to institutionalize good practices and demonstrate that you're doing things for the good of the company, rather than to free up some time in your day. Do it in the name of "continuous improvement," and you'll be a hero.

    6) You usually get two shots to make a pitch for a change. After that, you need to do your best to implement things the way your boss wants them. Anything more, and you're simply challenging his/her authority.

  50. The answer of course is "it depends". by fooslacker · · Score: 1

    What most developers/tech staff don't realize is that code reviews rarely result in a significantly lower bug rate. Proper unit, integration, and user acceptance testing is your best defense against bugs. What code reviews do provide is increased code quality with regards to style and supportability as well as some cross training that can benefit support efforts. It can also benefit performance and other NFR areas as expert developer help novice developer find less efficient code but if your testing properly tests your NFRs this is less likely to be of any financial benefit other than the growth of your developer staff that might help in a future effort.

    If you have problems with operating / support costs due to poor quality code and code of drastically different styles from different developers then code reviews can help but only if you write good code standards first so everyone is writing to the same standards. This becomes more valuable as the size of the organization grows. If you have 10 developers the benefit is probably minor compared to if you have 100 developers.

    In general I'm pro design review in ALL situations and I'm pro code review only in instances where I have operating / support issues.

  51. Dijkstra's troll by Anonymous Coward · · Score: 1, Insightful

    The purpose of the few coding reviews I have assisted was only to improve code metrics in order to avoid:
    - too much nesting
    - too long procedure or files
    - languages syntaxes that are rarely the best one (operator ?, struct in C++, ...)
    The modified code has far better metrics, but has exactly the same number of bugs and is less readable because of the late cueless refactoring.

    I hate the article of Dijkstra about the Goto, because of these practices that degenerated from it.
    Computer programing should be an art form like poetry and music (D. Knuth) and shall not be restricted to a subset. It is as stupid as refusing alterations in music or avoiding rare words in books.

    1. Re:Dijkstra's troll by Anonymous Coward · · Score: 0

      ? : is great for doing short-circuiting case/switch statements in Perl.  Something like:

         firstCondition()  ? doFirstOption
      :  secondCondition() ? doSecondOption
      :  thirdCondition()  ? doThirdOption

      Too much development time is wasted on object-orientation as the solution to our problems.  Patterns are a cesspool of boilerplate.  Programmer time would be much better spent normalizing the data they have to deal with coming up with expandable data structures and functions on them instead of faking it with class and object hierarchies, as is commonly done in the name of "maintainability".

      For example, suppose you are writing a renderer for a small fragment of HTML -- say a couple of tags and attributes conditionally.  Hows should you approach that?  With an HTML class and tag objects?  Why bother when you can make an array of hashes?  If you follow a few simple principles, the normalized data approach will still be maintainable, and expandable.  Throw in function combinators to abstract the act of gluing functions together, and you have a robust and adaptable system, with entirely uniform syntax and modularity as finely grained as desired.

      Indeed, an "object system" is just a funky function combinator designed to traverse a class hierarchy.

    2. Re:Dijkstra's troll by Omnifarious · · Score: 1

      In my opinion that's the result of people substituting arbitrary rules and stupid policy for human judgement. That's not how good code is written. Code is a craft, not wholly an art or an engineering discipline but something of both.

      And simply completely avoiding the use of ?: or (in C++) the struct keyword is, again, substituting arbitrary rules for judgement. They are both useful constructs that are perfectly valid in certain situations.

    3. Re:Dijkstra's troll by Ihlosi · · Score: 1
      The purpose of the few coding reviews I have assisted was only to improve code metrics in order to avoid:

      Err ... that's not the job of a code review. Make some coding guidelines and stick with them, e.g. no more than X levels of nesting unless you submit a written statement of necessity, functions should be no longer than Y lines (exceptions allowed), etc.

  52. No, they're not worth it. by kimanaw · · Score: 1
    Code reviews are highly subjective, human endeavors. I've certainly wasted more than a little of my life in "reviews" that were nothing more than personality driven, agenda laden time-wasters that usually surfaced little more than grammatical erros in comments. *If* the reviewers actually bother to look at the code before making comments.

    Here's a little exersize you might want your boss to be involved in:

    • Grab an arbitrary piece of code from outside your organization.
    • Inject 10 or so errors or other issues into it
    • Divide your usual review crew into 2 groups to review the code separately.
    • Tell one group that the code was written by a new intern, so you'd like them to eyeball it.
    • Tell the other group that the code was written by your most senior developer (preferably, one w/ a big ego), and they need to review it "cuz the boss says we have to"
    • Compare how many issues each group finds/reports.

    I suspect you already have a good idea what the outcome will be. That should be enough to tell you how effective code reviews are.

    Automated code formatters/code inspectors, along with decent compilers/linkers (or interpreters) will surface most of the issues that code reviews find.

    Instead of pissing away valuable developer time, put those reviewers to work writing and executing tests. Right away, you'll discover whether the code is testable. And then you'll discover whether its actually correct.

    Tests don't have egos, agendas, personal axes to grind, or coworkers they don't want to piss off. They don't take vacations or sick days. They don't have opinions about the author of the code. They usually don't leave the company. They generally don't have an opinion about how many/few comments there are, or if the code has been formatted to corporate spec (unless those tests are executed as part of the automated tools mentioned above). Sure they can be drudgery to write, but its the only real way to know if the code actually does whats its supposed to.

    --
    007: "Who are you?"
    Pussy: "My name is Pussy Galore."
    007: "I must be dreaming..."
  53. Hidden cost to not doing them. by Improv · · Score: 1

    It's not entirely about what they reveal once they've been established as good practice - there is also the fact that knowing that they will be done leads people to treat their code more carefully to begin with. In the deepest sense you'll never be able to compare what your code would be like if you did not have them - this is definitely not equivalent to what they turn up.

    --
    For every problem, there is at least one solution that is simple, neat, and wrong.
  54. Code Reviews - Waste of Time by Anonymous Coward · · Score: 0

    The sooner people realize that specialized Programmers are a thing of the past and that System Designers with DBA and Programming understanding will be the future the better. Microsoft already has an application creator based on your DB and the full ability to customize your template for the app creator so you can fix bugs in the root and deploy that template out for any web application you have. This is the future and debugging and documenting the logic and syntax of the code is a waste of time. Document out the flows and build the DB first and then the program 2nd and rely on the database instead of the actual program will save companies millions in the long run. Local Windows applications and Web Applications are going to merge soon into 1 platform that is universal and the sooner you prepare for this the better. Check your design and database that follows that design, you will get a whole heck of a lot more than you would from checking the code.

  55. WTF does maybe mean? by lalena · · Score: 5, Interesting

    Are code reviews useful?
    Lets see. Right click -> View source this web page. In the first 10 lines I see a variable called maybe with no comments as to what it means.
    Yes, code reviews are useful.

    1. Re:WTF does maybe mean? by Anonymous Coward · · Score: 1, Insightful

      +1

      A big part of the benefit comes from the coder putting in the extra effort to make the code review-ready. You may not get many changes coming out of the review itself, but the benefit has already been realized.

    2. Re:WTF does maybe mean? by Anonymous Coward · · Score: 0

      nice...

    3. Re:WTF does maybe mean? by systrace · · Score: 1

      Point taken, but perhaps "view source" doesn't show you the original source. It makes sense that they would strip comments before putting it on the server. I

  56. Bad Analogy Guy where art thou? by linzeal · · Score: 2, Insightful

    Best code reviews I have seen cost a lot of money in man hours and are usually are done by an in house group that specializes in it. For the last firmware review (2048k ASM) we had 3 salaried guys making over 120k a year spend 3 months on it to find 4 critical bugs and dozens of lesser ones. Shipping that firmware would of made us liable for over 2 million dollars worth of hardware. So if you look at it another way ~1/20th of the cost of the product was invested in the final code review.

    Having the same group review their own code is like the fox guarding the hen house, he might be a vegetarian but I doubt it.

  57. Absolutely by dFaust · · Score: 1

    I've actually been going through the process of getting code reviews as a standard process on my own team. We've done them now and again in the past - often on other team's code that was being integrated into our platform - and it was typically a pain.

    Enter A Good Tool(TM). We've been demoing some code review software lately and after settling on a particular tool that we find to work well with our workflow, the team has unanimously agreed that they find reviews beneficial. We don't have strict policies on how/when reviews are done, so it's encouraging when you see people are creating new reviews for their code of their own volition.

    While we haven't found a lot of critical bugs, we have found lots of minor things, problems/shortcomings in unit tests, documentation problems (especially important because we provide libraries to other teams, we're not the sole users of the code), and even pre-existing bugs while doing maintenance. I think the biggest benefits, though, have been getting more eyes on the code to increase familiarity with it so it's easier for other people to do maintenance and bug fixes on when the original author is unable to as well as just generally opening up broader communication about various elements of style, consistency, improving code readability, etc.

    The software says we've logged about 16 hours in the past month, across 7 developers. That's a pretty minimal investment. There was mention of good functional testing being all you really need, but if you're working on libraries and such it's easy to have bugs that don't show themselves in all usage scenarios. If well after a release another team manages to find a previously unnoticed bug in a library, the cost for them to track it down to our code, for us to fix it, put through QA, do a new release, pass off to the other team who then has to put their component through QA and deploy.... we've just burnt through a lot of time and money.

    Will code reviews lead to perfect code? No. But I would undoubtedly say that there are plenty of benefits that make them well worth it if they're done in an effective fashion.

    By the way, the software we settled on is Smart Bear's Code Collaborator, having also tried Crucible and Review Board as well as talking to other divisions about their experiences with code review software. It may not be the right tool for you, but we found it lets us bust through both initial reviews of the code as well as follow-up reviews to ensure any issues are being resolved appropriately. It's not the cheapest, but if it's the difference between a tool people will willingly use or a tool/process that people will bemoan, it's worth it.

  58. As you say... by nicoleb_x · · Score: 1

    As you say, they have no value in your environment. OK, maybe your team can't do reviews, maybe there is no point as the code is just a bunch of UI junk that changes constantly. It's no big deal. Not every team uses every software development technique, nor should they. I happen to write lots of code as a team of one. I'd like to get others to look at the code but that isn't going to happen, so no code reviews. I still get paid, applications work, customers are happy...it can be done.

  59. Cardboard cutout dog by Anonymous Coward · · Score: 0

    Cardboard Cutout Dog

    Possibly the finest essay on the subject.

    Jokes aside, it basically posits that the value of the code review is not in the listening, but in not letting your ideas stay in your head as a ball of fuzz, and force you to make them concrete by talking to someone/something. Tends to be true about code, and many other things.

  60. Desk checks vs code reviews by Anonymous Coward · · Score: 0

    In my organization we separate "code reviews" and "desk checks".

    Code reviews are formal meetings as described in several of the previous threads where you may call in a host of designers who sit down in a conference room, trying to dissect the code. These reviews are held seldom and normally only for major code changes which often affects other subsystems, to find ensure that the changes will not cause unexpected behavior of the system. This is very expensive.

    Desk checks is when you call a team member over, show the code, and describe the changes you've made. This is obviously very cheap.

    We have no hard statistics on the number of faults found in desk checks, but the general opinion is that they are very good to perform because:

    1. everybody can find time to perform them
    2. the coder receive a confirmation from a second mind/pair of eyes that there are no obvious faults
    3. even though faults are not often found, the return of investment is high due to the low cost.

    We plan to enforce desk checks on ALL changes. Code reviews will be reserved for the special cases.

    However, desk checks and code reviews will never ever be able to replace a solid regression test. Desk checks are a compliment.

  61. Statistical evidence that code review is worth it. by kfogel · · Score: 1

    For some statistical evidence (built on a very small sample size) that code review is worth it, see this section of a chapter from O'Reilly Media's book Beautiful Teams:

        http://www.red-bean.com/kfogel/beautiful-teams/bt-chapter-21.html#gumption-sink

    That section is not about code review per se (it's about how a seemingly trivial interface decision affected code review), but it includes some code review stats from two projects, and discusses how frequently one project's code review catches mistake from previous changes.

    (Disclaimer: I wrote the chapter, but it seems pertinent enough to this discussion to be worth posting.)

    --Karl Fogel

    --
    http://www.red-bean.com/kfogel
  62. Well, if we go by industry practices by 93+Escort+Wagon · · Score: 1

    It's pretty obvious Electronic Arts did away with code reviews many years ago.

    --
    #DeleteChrome
  63. Ask your developers by wrook · · Score: 1

    Lots of good replies here, so I won't touch on whether or not code reviews are beneficial. But one thing jumps out at me from the question:

    "I'm a development manager... I asked my boss to consider whether it was worth spending so much time on examining built code..."

    I hate to say it, but you are the wrong people to be considering this question. Code reviews are for programmers. It's good to hear that your reviews are developer led, but you've got some serious problems if you are trying to make this decision on your own. In fact, I'd go so far as to say that you have serious problems if you are attempting to make this decision at all.

    Certainly, a development manager's role will involve some coaching (unless you hire a senior developer whose job is specifically geared to coaching the developers -- something I highly recommend). In that coaching role, you could of course guide inexperienced developers towards practices that work well for the team. But at some point practices should be self-selected. The developers can see much better than you can what is worth doing and what isn't.

    It's appropriate to gather metrics and ask question about what is effective and what isn't. It can be a launching point for good discussion. But if your opinion of your developers is so low that you think you should make this decision, then you've got problems. Either you need to replace your developers or (more likely) get an attitude adjustment.

  64. Not much, it doesn't by Anonymous+Brave+Guy · · Score: 4, Insightful

    If it's ever not more economic to do code reviews, then I respectfully submit that You're Doing Them Wrong(TM).

    The improvements in the general standard of code, and consequently its maintainability, should easily outweigh the modest time spent on reviews. Likewise, the efficiency benefits just from sharing basic awareness of how various systems work and useful coding techniques around a development group should be enough to justify the time spent. And those are both without allowing for any actual bugs that would have been observed by your customers but got fixed much earlier and cheaper because the review caught them.

    Incidentally, if you don't think it's worth getting even a quick glance from a second pair of eyes on even a small bug fix, you should look up the research on how many bugs originate from a one- or two-line change to the code. It's a staggeringly high proportion.

    Now, a lot of places have tried full, Fagan-style, heavyweight reviews, and yeah, those pretty much suck for most software development groups. But that doesn't mean you can't employ a lighter process with the same goals. With the kinds of tools available to co-ordinate reviews and annotate code these days, your overheads should be near zero and you can do a lot of the work on-line rather than shoving everyone into a room for a few relatively unproductive hours.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Not much, it doesn't by Anonymous Coward · · Score: 0

      If it's ever not more economic to do code reviews, then I respectfully submit that You're Doing Them Wrong(TM).

      I'd have to agree. There is tons of technology to help you with the process. It should never come to an economic point of view.

  65. TDD vs. code reviews: "untestable" properties? by jonaskoelker · · Score: 1

    If you did test-driven development then code reviews would be redundant.

    No, not for everything.

    I'm currently fitting a wiimote-shaped peg into an XTest-shaped hole. I find that I can point the nunchuk upwards by a larger angle than I can point it downwards. The code that reads nunchuk data should compensate for this fact somehow.

    I'm not really sure how you write a test method for "Wiimote should be pleasant for human hands to hold and operate". Nor am I convinced that I would have found out my discovery without exploratory coding, something which TDD forbids or at least discourages and frowns upon ("write tests first").

    At least, if I get what TDD is all about.

    1. Re:TDD vs. code reviews: "untestable" properties? by Blakey+Rat · · Score: 1

      I posted further up the thread, but to re-iterate: you're entirely correct. TDD is 100% useless for testing any code with a user interface. If your entire job is writing business logic code buried deep inside an accounting program, then I'm sure TDD is the best thing since sliced bread. But you have to realize it doesn't work for every situation, or even many situations.

      And hell, entire technologies. Try writing useful tests for the Javascript layer web-application sometime. Ugh. There are "tools" out there, but none of them allow you to, for example, mock-up a "Window" object with a particular set of properties (say, a ridiculously high DocHeight.) You end up writing all your actual code in stub functions that do nothing except abstract the browser objects to make them testable. It's a ridiculous waste of time and bloating of code.

    2. Re:TDD vs. code reviews: "untestable" properties? by Jane+Q.+Public · · Score: 1

      As I mentioned about just a moment ago, that is not quite true. If you are talking about Web interfaces or Web pages, there are some extremely good tools that can be used to do testing... even automated testing. However, most of them only see the originally generated page, and so are insensitive to changes made to the page via JavaScript (Ajax, for example). One exception is Watir, or its cross-platform cousin FireWatir. The Watir variants can see the current DOM, no matter how many JavaScript functions or Ajax calls may have modified it. I have been using Watir on and off now for about 3 years.

    3. Re:TDD vs. code reviews: "untestable" properties? by Jane+Q.+Public · · Score: 1

      Oops. "mentioned about" = "mentioned above"

  66. I think they can be good by jonwil · · Score: 2, Insightful

    As a programmer, having someone else look at my code is good since there will always be mistakes I just cant see from looking at it. Someone else looking at it might pick them up when I cant, especially if they have more knowledge of bits of the codebase than I do.

  67. Code reviews are for more than just finding bugs by davebaum · · Score: 1

    Yes, code reviews are nominally about finding problems with the code, but they can also be used to...

    * Share knowledge. You can learn a lot of new things by looking at someone else's code. Perhaps they use a library class you aren't familiar with, or have used a language feature in an elegant way. Just as an artist will look at other artist's work as part of their growth, programmers shouldn't be working in complete isolation. And even if you are the amazing guru that knows everything, then at least your teammates will be able to benefit from your vast knowledge.

    * Ensure that every line of code has been seen by at least two people. Code that has only been worked on and looked at by a single person is a liability. If they leave the company (or project or whatever) you suddenly have this huge morass of code that nobody is familiar with, and you probably only start to realize this when there's a nasty bug that needs to be quickly fixed in that code.

    * Tests can help with correctness, but do not necessarily make the code maintainable. Even if your code is correct, if a question comes up in code review, then that's an indication that you need to write clearer code and/or better comments if you expect anyone else to be able to work on the code in your absence.

    That being said, a bad code review is probably not worth it. Keep the amount of code being reviewed at a single time relatively small. Don't involve too many people - just one other person looking at the code will provide a lot of value at minimal cost. If you start inviting managers and "process czars", then you're on the wrong track. Review code promptly: one-on-one reviewer led discussion works well (they read your code and ask you questions as they go). Code review tools can help, especially if the programmers are in different time zones. Everyone needs to make reviews a priority - aim for 24 hour max turn-around on a review otherwise you'll find everyone always being blocked. I think letting the author pick the reviewer(s) is important. That way if someone is a complete jerk about code reviews, nobody will ever include them in the reviews and you have minimized the damage that person can cause.

  68. Simplify them by ergun+coruh · · Score: 1

    I am an experienced principal software engineer and team lead in a software house. Code reviews are essential part of our development process. Having said that we avoid lengthy reviews. We don't have review meetings, forms, sign off procedures, the stuff that put people off. Code reviews are a conducted entirely online via Jira forms, using a simple set of workflow rules. It is a non-intrusive, friendly process. I am considered to be one of the best coders, but I am not flawless. I find it hugely valuable for someone (at least as experienced as myself) to review my code. Even if I have the chance to slip it, I won't. It is for my own benefit. Most ideas are subjective and they pop up in human consciousness. I am not talking about detecting simple errors, but issues more of structural, the ways you structure code; i.e. efficiency vs maintainability, or generality vs usability. I don't believe there is a machine process out there that can successfully replace a human reviewer to find the optimum between these extremes, at least not for another 100 years. To sum up, "don't give up code reviews, but simplify them, make them developer friendly".

  69. I like having my code reviewed by HomerJ · · Score: 2, Insightful

    Which goes against the thinking for a lot of developers. They seem to take reviews of code personally, and believe everything they did is correct.

    I go the other way. If my code is good, it will stand the test of a review. If one or a group of my colleagues looks at my code and doesn't find a fault then I KNOW it's good. I don't have to just THINK it because I believe so. If I can't explain why I did something in a review, it shouldn't get into production code.

    Sometimes it's even simple stuff. I Do X, and someone goes "oh, we had to do it too, and wrote this bunch of code for it. Maybe we could combine the code into one usable module for both". It's stuff like that you can only really do in a good code review. It shouldn't JUST be done at a commit. It's something that should be part of the development process.

  70. Talk to the bear... by argent · · Score: 1

    At my last job we called this "talking to the bear".

    We found that occasionally slipping a live programmer in in place of the stuffed bear improved the quality of the process.

  71. Not for bug catching by hardcode57 · · Score: 1

    You won't catch many bugs code-reading, but you will keep up the quality and maintainability of your code.

  72. I want ALL my code reviewed... by MadShark · · Score: 2, Insightful

    My company has a pretty rigid set of processes and we find that we catch approximately 25% of our defects in code reviews. This doesn't count minor things like not following the coding conventions or bad comments, those are logged separately. We have reviews where we hand them off to just one other engineer as well as the Fagan style of reviews, depending on what we feel is appropriate for the particular piece of code. In our industry(embedded software), it isn't exactly easy to push out a patch once the code is released so that plays into how/why we do it the way we do. I wouldn't say the review process is cheap, but neither are warranty campaigns. Pay it now or pay it later I guess...

    Even the best people occasionally typo, put in a bad/wrong comment or just flat out make a mistake during coding. Personally, I'd love it if we had the resources to review every single line of code I write.

  73. Versus pair programming? by sdhoigt · · Score: 1

    At work we're currently in a heated debated whether we should adopt peer code reviews (what the boss wants) or paired programming (what us devs want).

    We feel that paired programming provides all the benefits (and them some) of peer code reviews but doesn't have all the cons of peer reviews. Here's a quick run down of what we came up with.

    Pros for paired programming:

            * A natural knowledge backup is created (2 devs know how the new code/design works)
            * More sound design decisions can be made during design/development stages (two heads are better than one).
            * Complex problem solving.
            * Fewer bugs. Better quality product.
            * Less total overall time spent coding/maintaining.
            * No new software to purchase/install/learn (I.e., peer code review software - Review Board, Crucible, etc.).

    Cons for code review:

            * If the design decisions are poor and need to be reworked, we don't find out till the code review.
            * Code review step likely to get skipped with tight deadlines.
            * Chance for egos to get bruised.

    I'd appreciate anyone else's comments on this comparison.

    Thanks!
    SD

  74. Depends on the purpose of the code review by Prototerm · · Score: 1

    One company I worked for did regular code reviews. Unfortunately. It quickly became an annoying waste of time that devolved into punctuation checking. The only thing that mattered was how many spaces were used to indent lines of code, how many blank lines were between subroutines, whether dashes or equal signs were placed before and after comment blocks, and other minutiae of meaningless, non-functional detail.

    Unfortunately, and I'm sure this will come as a surprise to everyone, this did little to improve the quality of the software, or reduce the number of bugs.

    But, hey, at least QA had job security, you know? I guess that's something.

    --
    "My country, right or wrong; if right, to be kept right; and if wrong, to be set right." --Senator Carl Schurz (1872)
  75. Well i dont know... by drolli · · Score: 1

    how many programmer are working with you. Can you exclude some of them are assholes? Can you exclude some of them are hating their job, want to leave tomorrow and are waiting to sabotage something? Can you exclude some newly hired guy is inexperienced or an idiot?

    Well if nothing of that matters to you, you don't need anybody having looking at their code. However if something bad (sbdy of your shop stealing data etc....) happens and you will be asked if you had a well defined procedure how code enters you codebase, it might save your ass if you had code reviews.

  76. You may not be doing them right by crmartin · · Score: 1

    Honestly, code reviews, historically, have proven to be about ten times as cost effective as other techniques. If you're not seeing good effects from them, the odds are that you aren't doing them right.

    Not that this is a big surprise, as few people do them well.

    Get hold of some of the literature on Fagin reviews, and make sure you're following the guidelines:

    (1) not too many people in the review: 3 minimum, 7 maximum.
    (2) the programmer isn't allowed to speak, except potentially to explain something
    (3) no one can suggest solutions: identify a potential problem and move on
    (4) close the loop: make sure all solutions get documented and passed to review participants.
    (5) a single review can last no longer than 1 hour.

    1. Re:You may not be doing them right by Chris+Pimlott · · Score: 1

      (3) no one can suggest solutions: identify a potential problem and move on
      (4) close the loop: make sure all solutions get documented and passed to review participants.

      Er, where are these solutions you're documenting coming from, if no one is allowed to suggest them?

    2. Re:You may not be doing them right by crmartin · · Score: 1

      NO one can suggest them during the meeting. Someone has to fix them after the meeting.

  77. should be nearly mandatory by OrangeTide · · Score: 1

    Get a software package or share "diffs" via email. You should really not accept code until at least 1 or 2 other people have taking a quick look through the changes.
    Code reviews are important not only to filter out mistakes, but to also make sure multiple people are familiarized with the code.
    But managers are really bad at handling special cases. Sometimes it's more important to commit code than to do a code review (at my work we can't svn commit until we put in Review Board entry that has at least two "ship its"), flexibility in process is also very important. Most companies don't "get" that, they just look for a silver bullet they can apply broadly.

    --
    “Common sense is not so common.” — Voltaire
  78. The only valid measurement of code quality by arkarumba · · Score: 1

    The only valid measurement of code quality
    http://www.osnews.com/story/19266/WTFs_m

  79. code reviews suck by Anonymous Coward · · Score: 0

    software is bugs. a code review may find a few, but it will miss many others, because most bugs are a missed/misunderstood/unknown requirement.

    and as for them being "a way to enforce various stylistic guidelines on code", that's simply a nice way of saying, "they provide a forum for pedantic programmers to pummel one another about stylistic ridiculousness.

  80. Our Experience by Javagator · · Score: 1

    I have always heard great things about code reviews. However, our company recently began a policy of formal code reviews and they have not lived up to my expectations. We rarely find any real bugs or serious design flaws. We find things like minor coding standard violations, or "you should move this statement here to make things clearer". While these findings may help improve the code, I don't think that they justify the time spent in review. And these reviews are turning out to be very time consuming, not to mention one of the most boring things I have ever done at work. This group of developers is one of the most talented and experienced groups that I have worked with. One would think that if code reviews would work for anyone, they would work for us.

    Incidentally, we do keep statistics on defects. Unfortunately, the minor improvements we find make it seem like we are finding a reasonable number of defects.

  81. The real value of doing code reviews... by The+Famous+Druid · · Score: 1
    ...isn't how much bad code you find.

    It's how much bad code never gets written in the first place, because the programmer knows his/her code is going to be reviewed.

    When you know your code will be reviewed, you resist the temptation to take the quick-and-dirty shortcut that you know will get picked up in a review, you do it right the first time.

    --
    Quidquid Latine dictum sit, altum videtur (anything said in Latin sounds important)
  82. Monk would love stylistic guidelines by ClosedSource · · Score: 1

    " First, they are a way to enforce various stylistic guidelines on code that make future maintenance much easier."

    Yes, I've heard that for many years, but have yet to see any proof that it's true. Perhaps stylistic guidelines are really used because of our compulsion to create order where none is required.

    Besides, checking those guidelines could be performed by any competent admin prior to a review.

  83. Sure they're useful if done right by NotSoHeavyD3 · · Score: 1

    Especially if the reviewer can force changes in other people's code as the result of it. I mean I had one where I had some logic that looked absolutely insane. This happened because I was using functions from another programmer and he had nonsensical return values which pretty much forced my hand. (I pointed this out to him but he refused to change it, claiming it was intentional.) The code reviewer asked why is it that way, I told him and he pretty much pulled rank and told the idiot to fix his code. (Unfortunately the idiot then had it in for me for the rest of the project and would go and whine and cry about every last little thing which didn't make things very good.)

    --
    Did you know 80 to 90% of the moderators on slashdot wouldn't recognize a troll even if one dragged them under a bridge.
  84. code reviews are too late by Alban · · Score: 1

    Code reviews are somewhat useful for small changes. But I find that for large changes, they are TOO LATE. If someone has gone forward and made non significant changes to your software, and you happen to catch his misconceptions during the code review (dependencies he shouldn't have pulled in, improper encapsulation, volatile and frequent usage of memory, etc), he won't be able to just "address" your concerns with a few changes. He basically has to scratch most of his work. And unfortunately, few managers will see the benefit of "implementing something" better since that requires more time, and the feature as implemented "works".

    Likewise, when the software design is done too long before the actual task gets to the implementation phase, the design may be out of touch by the time you get there because new constraints and problems have been discovered since the design phase.

    That's why I like to have quick whiteboard sessions before someone starts implementing something. I like to know the dependencies their module will pull in, the services it will require, I want to make sure the module is kept as ignorant as possible in terms of what it knows about the rest of the system, etc. When those things are caught early on, is it almost free to correct them. But later, there is a cost. If the task is long, I like to see multiple snapshots along the way to again course correct anything before it gets too far down the road.

    I work at a large video game company. I don't believe things always were the way they are now, but right now everything is tasked against "features" and it is hard for most managers to understand the necessity of infrastructure work, of unit tests, of proper module encapuslation and definition of dependencies (otherwise you find your unit tests impossible to write using your module's public interface). Every sees the short term. It is easy for them to understand that something is done when they see it in the game. But it is harder for them to understand that you want to make the process of software development more predictable, you don't want half the features in the game to be broken half the time and the shipping product to just be an instant snapshot of working features that will break as soon as the next cycle starts.

    So, code reviews are useful, but they really aren't the most useful thing since they occur TOO LATE.

  85. Code Reviews via the web by 787style · · Score: 1

    We have recently started doing code reviews using an online tools that ties very nicely into our SCM tool. All code changes have an associated defect or enhancement ID, are developed on a private branch, and prior to being integrated into the trunk have to be review by a member of a pool of subject matter experts. Since the team is world wide, having a web system to communicate between the various sites allows for faster response time, and helps ensure consistency in standards throughout the regions.

    The product is by a company named Smartbear, called CodeCollaborator. Very pleased so far, http://smartbear.com/.

  86. right and wrong ways by micromuncher · · Score: 1

    As with any software process, there are right and wrong things to do. First, the formal code review where invitees don't review the code in advance are pointless. Usually there is so much to go over, even if these are scheduled frequently, that anything more than surface is missed.

    And then when you have a developer do a package and walk through, there are people not to invite. I've been in reviews where all but one of the reviewees took it seriously, and the one that did not, effectively wanted to review everything in the meeting because they didn't study the prep. Only invite reviewers that take it seriously.

    A lot of unorganized code reviews degenerate into style comments and surface stuff. This doesn't help; the most important thing is to have reviewers that bring in their own findings like an audit. You can delegate things from developer to reviewer, like one reviewer could run through a profiler (ie java findbugs), another through metrics (ie java metricsreloaded), or another with specific data structures and algorithms expertise or concurrency attention. So... each reviewer can have a role. Each reviewer is a subject matter expert.

    The best ones in my opinion are where the developer runs the code through a metrics tool to identify hotspots, like complex code, or things that have complex entry/exit conditions. Things where the developer actively wants to solicit opinions. Like... "How the heck can I test this?"

    Again it falls to the people though. Artifacts are really important, as are action items and follow up. Another example; one review I was in we spotted a developer using floats for guids. We explained why this was a really bad idea, but because we didn't follow up on it, and neither did the developer, I spent a week hunting down a duplicate spurrious guid conflict. The team was pretty upset with the developer for not actioning a fix, but our management believed that buy in to process was optional...

    Good luck. Reviews show professional acumen, but there needs to be some discipline in the prep, review, and follow up.

    --
    /\/\icro/\/\uncher
  87. Read an XP book by Anonymous Coward · · Score: 0

    XP advocates to pair program 100% of the time. I would suggest that you guys try to work pairing into your development schedule. Most people are afraid because they feel as though it will slow down their velocity but it should actually accelerate it. You'd be done with the lengthy code review process, which is silly in my opinion. It's almost always better to have 2 eyes on code than 1. It keeps the developers engaged if they ping pong back and fourth (taking turns to code/test). It reduces the number of bugs. It increases the readability of the code (now both have to agree on how readable it is). It also helps spread the knowledge amongst more than just a single person (what if one got hit by a bus the following day?).

  88. Hire programmers who don't get hit by busses. by N3Roaster · · Score: 2, Funny

    I keep hearing about these programmers getting hit by busses. In fact, I think I hear about programmers being hit by busses more than members of any other profession. Now, the busses that I've seen tend to be rather large things that stop frequently, and usually aren't going very fast. The generally poor quality of code suddenly makes a lot more sense when you consider that it is being written by a class of people who are so fatally inattentive as to be struck by busses with such improbable frequency.

    --
    Remember RFC 873!
  89. Respect for the upcoming review improves code by freshfromthevat · · Score: 1

    Many programmers will improve their neatness and attention to coding standards if they know the code review is in the future.

    --
    .. Blub falls right in the middle of the abstractness continuum. -- Paul Graham
  90. How not to do a code review by kybred · · Score: 1
    Here's some rules to insure your code reviews go badly:

    1) You want the meeting to be the first time you've looked at the code. That way you can ask a lot of questions that could have been answered in two minutes of reading the code (and thus waste minutes of everyone's time).

    2) Don't assign roles. That way everyone can look at the code from the same viewpoint.

    3) Don't stay professional or objective. Ad hominem attacks always help in reviews.

    4) Don't set a time limit. Everyone loves meetings that drag on and on.

    5) Be sure to review at least 5,000 lines of code in each review.

  91. You are TOTALLY doing them wrong by MobyDisk · · Score: 1

    code reviews take forever and tend to reveal less than good UI-level testing would

    WOW. Just WOW. You must be doing a numer of things incorrectly. Let me offer some suggestions: (Although, UI testing is definitely a pre-requisite here, and nothing will find more bugs than just using the software.)
    1) Everyone must read and understand the code before the review.
    2) Allocate time in the schedule for code reviews.
    3) 4) No bosses, managers, testers, or other non-coding positions in the review.
    5) Do not read the code line-by-line or even function-by-function.

    Everyone should have the code marked-up with comments and questions prior to the meeting. The goal of the meeting is to go through those, not to go through the code itself. The meeting should start with: "Author: Has everyone read the code?" If there are any "No's" then dismiss the meeting and those people can read the code during the time allocated for the meeting. "Author: Are there any major design, or module-level questions or comments?" This is the time to address major items like using the wrong tools, libraries, etc. (Although in theory, those were caught during a design phase, but it can happen) Now, go through the comments and questions. Or go function-by-function if you can. Maybe with "This function does X: Any comments or questions? Next. This function does Y..."
    At this rate, you should be able to review weeks of code in an hour.

  92. Yes it's a waste of time unless.. by Anonymous Coward · · Score: 0

    Unless you have a bunch of 2-bit hacks fresh out of tech school/Uni. Otherwise good programmers can review their own code safely and effectively. Using automated styling-enforcement in Eclipse will keep everything clean and 99% of all algorithms you need are just library classes which have already been reviewed and optimized.

    Now if you're a code-shop using .net and $5/hr Indian programmers...

  93. It's a good start that a code review is an option by Scroatzilla · · Score: 1

    I remember when I first started my current job, in a web developer position. We were using "templates" for developing custom products. The templates had about 90% of what was needed at any given time, but when I was first given a task that was essentially a new feature, I asked naively, "How do we handle this? I see that we're using templates, but this is new. I'd like to code this so that everyone could use it."

    That was met with bafflement. As it turns out, every single developer-- when faced with the same situation-- had simply added to his/her own stash of code that was never shared. Therefore, a lot of time was (and probably still is, I'm not a developer anymore) wasted re-coding stuff that already existed. That is because the notion of delving into code, with the intent to share knowledge in a meeting, was a foreign concept.

    Somewhere in between "zero" code reviews like the situation that I was in, and spending zillions of hours on tedious code reviews which may or may not be useful, there exists the right balance. Like anything other situation, you should avoid useless meetings. But if you have a particular project that would benefit from it in some way-- either from a re-usability or a time-saving or a code maintenance perspective-- I think it's worth it.

    As always, the obstacle is finding someone in management who understands these concepts. I haven't figured out how to effectively explain the "obvious" to PHBs. You would do well to consider communication as a key necessity when wrestling with your question...

  94. Re:Hell Fucking No by Anonymous Coward · · Score: 0

    Curry is easier to clean. I wonder what you do when you find Hamburgers between 1's and 0's.
    You probably eat it.

  95. Core Reviews. by Z00L00K · · Score: 1

    Some code reviewing is validated but much of the tiresome review work can be resolved by automatic tools these days. Tools like Lint and FindBugs.

    But a review to make sure that the code is easy to understand and maintain is a different issue that can't be addressed by automatic tools. At least not until you get a tool that can semantically understand comments.

    --
    If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
  96. Code Review Ready by wonkavader · · Score: 1

    I think this is actually the most obvious and non-controversial aspect of code reviews, and yet I don't see it mentioned anywhere above.

    Shame. Pride. Vanity. Whatever. You know other people will look at it, so you make it look better. You take another look at it as if someone else might actually need to understand it, and you make it better before the code review.

    That's an absolutely wonderful effect, even if the code review is a bunch of grunting and a rubber stamp.

  97. Absolutely by Anonymous Coward · · Score: 0

    Code review provides huge benefits. It may seem like a lot of work to find "just" one or two bugs an hour (and typically a good review will turn up at least that) but those bugs can be fixed without engaging a full QA cycle. The bugs turned up are often also exactly the kind that don't reliably turn up in test like memory leaks and race conditions. I've seen situations where just a identified issue provided savings that justified the entire cost of the program. Those are pretty serious issues but even a typo can produce considerable paperwork if it gets into a release (test>triage>dev>fix>retest).

  98. Security Camera Effect by zuperduperman · · Score: 3, Insightful

    The primary effect of code reviews has nothing to do with finding problems during the review itself. It improves quality before the code ever gets to review, because people care far more about what they do in the first place if they know there is even a chance others will see and criticize them later for doing it wrong.

    This is why stores put up fake security cameras. The notion that they have someone sitting there watching the camera continuously is ridiculous, yet a camera has a huge effect on people's tendency to commit crimes nonetheless.

  99. Depends on which stage of development you ask... by freedom_india · · Score: 1

    It entirely depends on which stage of development you are.
    If you are early in the cycle, and just building PoCs to validate architecture and design, then code reviews will be great in establishing basic discipline.
    If you are late into development and want a code review to find out issues in design, then sorry, you are too late.
    Code reviews establish base standards BEFORE the battle.
    Like battle readiness inspection of troops.
    It tells how you will code under fire.
    But once the battle starts, you don't conduct inspections, because they are a waste of money and hell they do nothing.

    --
    "Doing what i can, with what i have." ~ Burt Gummer
  100. Productivity by Tim12s · · Score: 1

    The biggest problem with today's code is yesterday's code.

    If you want to be productive you must have good code to begin with.

    Its very difficult to start doing things correctly when you're working with code that is a ball of mud.

  101. You got it exactly right by melted · · Score: 1

    I was about to say this. I've worked with some really good developers and I consider myself "good" as well. We would not do code reviews for _all_ new code. We would ask each other to review particularly hairy pieces, though, which would often result in insightful and non-obvious refactoring suggestions, and rarely in finding bugs. Security related bits would always get a full-team review (including QA). Code reviews were required for all but the most trivial bug fixes, since they're cheaper and you don't always remember what the old code did 100%. Closer to shipping, two reviewers were required. There were very few bugs overall.

    I'm pretty confident that I can code faster and with higher quality than pair programmers of virtually any skill level. If they're bad, they'll inevitably churn out bad code (although it will be better than code written by just one bad programmer), and if they're good, pair programming will slow them down and lead to more defects because neither of the programmers will have the whole thing 100% in his head.

    1. Re:You got it exactly right by man_of_mr_e · · Score: 1

      Spoken like someone that's never really done pair programming.

      I think you misunderstand what pair programming is. It's not, one guy takes the keyboard and writes code for 10 minutes while the other watches, the trade off...

      Both programmers are active during pair programming. One may be physically entering it, but you're both writing all the code. And you're both keeping all the code in your head, otherwise you're doing it wrong and gaining no real advantage from pair programming.

    2. Re:You got it exactly right by melted · · Score: 1

      Um, no. You can't keep someone else's code 100% in your head 100% of the time, even if you're paired with the guy. Heck on anything non-trivial it barely works with the code you've written yourself. By "keeping it in your head" I mean being able to anticipate, with full clarity, the effects of changing a bit of code nominally unrelated to the code where you'd be causing change in behavior. Things like exception handling, exception safety, thread safety, concurrency, performance implications, validation, security, etc.

      You simply won't have the same level of grasp on the code written by someone else.

      Remember, the best code in the world is 100% written without all of this newfangled "agile" BS. Pick any successful open (or closed) source project and try to find one that uses anything Agile-related (XP, Scrum, PP). You won't find one.

  102. Code reviewes can be good or bad by Anonymous Coward · · Score: 0

    I work in a large programming shop. I've participated in both worthwhile and worthless code reviews.

    The worthwhile ones require preparation. During that preparation you read the code, dividing issues into two categories: minor and major. Minor issues go direct to the programmer and aren't open for discussion during the meeting. So programming style issues don't make to the the table. The convenor collates the major issues, and these are addressed in order during the walkthrough meeting.

    Of course, not all major issues are bugs. Sometimes issues are unclear code which must be tidied to make maintenance cheaper. Sometimes issues show a lack of understanding about the customer's industry -- for example, tying down a attribute of the problem in code which we know is open to change and thus should be configurable. Sometimes the issue is a misuse of a API, and this class of error can lead to a system-wide review (the classic error here being strcpy()).

    The reason programmers don't like code review is because they show what the abilities and limitations of the programmer and the reviewers are. They all like to dream that they are coding heroes, and reviews bring them back to earth. But as the technical lead I prefer that to encountering problems post-shipment. Also, I don't want heroes on my team; I want people who are self-aware, who know what they are good and bad at, who working to make the bad better, and know when to ask for help rather than shipping deficient code.

    The most important step to achieving good code reviews is to aim to do good code reviews. This means designing the review process so that it is effective. A three hour meeting which reads code which has not been viewed before, which criticises style over substance, which offends rather than teaches, and drags on missing the forest for the trees is a a failure.

    The other really important purpose of code reviews is to examine that 1% of existing code which is causing 30% of the fault reports. Don't allocate that issue to a programmer to work on alone. Allocate it to a programmer, and review the old code as if that programmer wrote it. Then the full force of the team's intellect and experience will be bought to bear on that troublesome issue. The effect on the programmer is also good -- they don't feel as though they've been handed the troublesome child to work on alone and unassisted.

  103. old answer by Anonymous Coward · · Score: 0

    It's an old question, and there has been some academic research on the topic way back in 1980. Probably there has been predecessors and successors to this one. This study marks peer code review and dynamic simulation as the two most useful methods.

    Take a look: Benefit Analysis of Some Software Reliability Methodologies by Robert L. Glass, http://portal.acm.org/citation.cfm?id=1010797

  104. Design != Coding by Anonymous Coward · · Score: 2, Insightful

    Until this is understood, additional discussion is futile.

    If pair programming is cost effective, you've hired the wrong programmers - pay more and get good developers (and, as a manager, set priorities to reward quality). Teach developers to desk check their own code -- every true "bug" found by your "pair" or missed by them but found by QA or the Customer should be viewed as a humiliating embarrassment by the coder - something that happens every few 10K of code but really requires a humble round of beer for the entire reveiw/QA team.

    Yes, part of Development is a creative process - but that's not an excuse for eliminating accountability or responsibility.

  105. What's more expensive? by Chris+Snook · · Score: 1

    Fixing a bug, or fixing a design flaw? If your customers aren't going to ditch you for the occasional glitch, and it sounds like yours won't, it's much more important to focus your resources on making sure that they have a good overall experience.

    --
    There's no failure quite as dissatisfying as a complete and total solution to the wrong problem.
  106. Code reviews are a question of life and death by GPLHost-Thomas · · Score: 1

    The recent story about HyperVM security holes teaches that code reviews can be a question of life and death. See the story on the register and maybe you will understand... Sad...

    Thomas

  107. Now that sounds... by Anonymous Coward · · Score: 0

    ... like a fun place to work.

  108. Control by DaveGod · · Score: 1

    Coming at this from a general control perspective, controls operate at both detection and prevention. The code reviews may not be detecting many problems, but their existence may have an impact anyway. If nobody is reviewing code at all, would people approach their task differently? What would anyone know about the software quality other than "it works"? The process may also be valuable to management for other reasons. What does anyone know about the programmer's level of skill? Is the code documented for maintenance?

  109. You get what you pay for by ohmiccurmudgeon · · Score: 1

    Over dozens of projects I've seen 2/3 of code reviews fail to yield tangible benefit, but the other 1/3 of the code reviews were wildly successful in finding defects. Primary difference between the successful and failed reviews was homework. In the effective reviews multiple reviewers spent about an hour before meeting to review the code in respect to a checklist of items to watch for. Those checklists did not address formatting issues that can be corrected with a code beautifier. At the review meeting each person presented their found defects, which led others to find other defects in a synergistic effect. The checklist itself was subject to review. Because everyone, including the programmer whose code is under review are trained in the technique, there wasn't the usual defensiveness or the feeling everyone is ganging up on one person. The expectation is that defects will be found.

    The reviews that failed, failed for lack of preparation, lack of formal standards expressed in a easily digestible checklist, and a lack of training so the sessions degraded into carping sessions about one person not liking another's variable names.

    A multiple person code review is an expensive proposition. I'd use it only on critical code and on public facing documentation.

  110. Reviews work by algoa456 · · Score: 1

    Code reviews work because when developers know their code is going to be scrutinized they improve their level of coding. I've run developer shops for over 30 years and I've found that no matter what level the developer, if they are aware that their peers will review their code that take more care over it. Will reviews make a poor developer a good developer? Of course not, but it will improve the quality, layout, documentation and general understanding that a developer has for the code he or she writes. And as a bonus poor developers can get insights from good developers when they sit in on reviews.

  111. yes! by adhocboy · · Score: 1

    Code reviews are valuable. Try both automated and human reviews. Automated reviews are as simple as coming to the table with a profile of the code and quick ratios that make sense to your application. We run scripts against our source code control system to 'score' certain things... even a basic % changed is useful in prioritizing human review. Finding redundant code is another good check. Human reviews can be useful with the right folks. Subject matter experts (on the problem space, not technology), senior engineers/architects, and SA/DBAs are always good. Don't waste time - bring it in, review the high risk areas. More reviews on common libraries, less (or none) on single use situations.

  112. What about the frequency of code changes by heironymous · · Score: 1

    I haven't seen anyone comment yet on how frequently the code under review will change. If you are writing a library or something that's going to be pretty stable, then the cost of a formal review is easier to justify.

    But if the code is unstable, and going to be modified over and over, then the benefit of a formal review depreciates very rapidly. For some industries and products, this doesn't matter. But for others, the cost of the formal review can be too high.

  113. Gods yes! by Fastolfe · · Score: 2, Insightful

    Just do them right:
    1. Each commit should have an explanation of what the change does, and should be small enough that the reviewer can do it quickly.
    2. Your organization should prioritize code reviews over other work; in many cases the review is blocking something.

    If your reviews are kept small, and are a high priority, they add enormous value and shouldn't negatively impact your work.

    Code reviews have the following perhaps non-obvious benefits:
    - They ensure the implementation does justice to the design
    - They help pass institutional knowledge to the developer ("This function has an existing implementation over here...")
    - They ensure code readability (especially when used with a formal style guide)
    - They help keep the developer honest, when he or she might take shortcuts or be lazy with a certain function.
    - By mandating code reviews, you have a pressure from the reviewers to keep each commit small, which encourages incremental development, which discovers design flaws early rather than after 10,000 lines are written.

    Code reviews aren't really a great place to FIND bugs. Yes, obvious bugs will stand out to an experienced developer, but the reviewer is another human, and he or she can easily miss the same bugs the developer missed. Really, unit tests are where you catch bugs, and a reviewer is usually in a better position to identify incomplete unit testing.

  114. Are code reviews a panacea? by lsatenstein · · Score: 0

    When I did code reviews, I first had to understand the problem being solved. Then, I did a walk through for a) function descriptions being documented, either by being apparent, or with explanation. I would verify that all return codes were being verified, and that an error return code was posted to a log, as well as being displayed. The result of that practice was 1) programmer had one or two bug reports on his desk the first week, and half the amount in the second, and by the third week, the program was considered clean. Month end programs were expected to be clean after 3 or 4 uses. yes, they are worth it.

    --
    Leslie Satenstein Montreal Quebec Canada
  115. Their code is a successful as their country. by Anonymous Coward · · Score: 0

    H1B Visa Indians modded the parent post "Troll".

  116. Depends on who the reviewer is by caywen · · Score: 1

    Ideally, the reviewer will understand the context of the code and the context of the review. Reviews should only be conducted by 2 engineers who both have a deep sense of what level is appropriate. I hate ending up with some ass who thinks every piece of code controls life and death, and happens to also think your variable naming is also going to kill people, too.

  117. Will you take action and fire bad programmers? by nicholdraper · · Score: 1

    Code reviews are only as good as the reviewer. I've worked for companies that do the team over-head approach -- mostly a waste of time. Pair programming -- valuable for some programmers, frankly I don't mind having someone look over my shoulder, but it's boring as can be to watch someone else program, especially when I'm faster. Reviewing code of a failing project can be very valuable, recently I was asked to look at another team's project at the company where I work. I took on a few assignments to complete parts of the project, I learned that they had spent a year of development time and money to write a database access layer. I reported to my boss that they had wasted the companies money, I rewrote my portion using the Microsoft supplied DataSet and showed a simple operation taking 4 seconds in place of 90 seconds. Fortunately my boss took the corrective action and let the team go. The entire review took about four months. I know that is not what you are thinking of when you talk about code reviews, but, just looking for bugs in code is not enough. You have to have a competent senior programmer who knows how to evaluate code. Two bad programmers are not any better than one bad programmer. Throw out the silly coding standards that say tab stops must be 4 spaces, and ask a good programmer to look at the code to see if he is willing to take ownership. If you don't know if you have a good programmer, ask a programmer to add a couple of automated unit tests to the code you want reviewed. That will result in a better code review than any meeting or pairing.

  118. Hard to say... by Anonymous Coward · · Score: 0

    I'd say it's hard to say. If you are going to be expected to keep adding features, or work on something else, then the code reviews would be useless -- you could find out some code is crap but would not be given the time to do anything about it, as long as it barely works. If you have some control over improving the product, then do code reviews. Sounds to me like your current boss is in the first camp, doing code reviews wouldn't help at all then.

  119. Mythical Man Month, Anyone? by mikehoskins · · Score: 1

    Then there's the powers of ten cost of fixing problems...
        Design = $1
        Development = $10
        Debugging = $100
        Deployment = $1000
        - Frederick P. Brooks
        The Mythical Man-Month: Essays on Software
        Engineering, Anniversary Edition (2nd Edition)

    Think of it this way....

    So, anything you catch in design costs you a "buck" for your effort. If you catch it during development, it *still* only costs you "10 bucks."

    If you wait until debugging ("100 bucks") or deployment ("1000 bucks"), you're hosed.

    You can be more or less effective during a code review, but as long as it catches stuff, it's still far easier, cheaper, faster, better to catch it there, than later... Yes, it may be 10x harder to catch during a code review than a design review. Well, you're just proving the Mythical Man Month to be true. Your boss knows it, too, and he's trying to stop the vicious debug -> deploy problem.

    Do you want screaming customers at 4:00a, calling you about some obscure error in a program you wrote, when it might be avoidable? Does your boss want to earn blame for a team of "bad coders?"

    I'd say that it's good that your boss wants this bit of extra discipline -- for your sake, his, the customers', and the company's....

  120. Code Reviews ... by Churam · · Score: 1

    The importance of code reviews depends of where you work and about how serious people making it are.

    As I see from where I am, code reviews at least tends to bring the code to be easily readable by anybody as it is made to enforce the programmer follow the rules set by the company.
    As for the cost of code reviews, you can manage them. Some part of it can be made with some script (parsing through files, check for unused variable, compute comment / code ratio by function, ...) to gives some hints to the reviewer to speed up is process and perhaps find something.

    As for now, you are working on non critical PC software but when you are on some low memory, old crap machines, you like to check if there is any memory leak, or at least memory fragmentation. those can be found with a code review before being found by a user (but yeah, the programmer should find it and fix it before he commits his code).

  121. In my experience... by jazzduck · · Score: 1

    In my experience, code reviews help the developer much more than they help the product. And this is a Good Thing.

    Take me, for example. A few years ago, I was just out of college, 9 months on the job with a global consulting firm, working on a large Java-based web application for a government department. I was assigned a complex and poorly-defined module to write. While my first stab at the module worked fine, passed unit testing, and satisfied all the functional requirements, it was kludgy and would have been inelegant for maintenance programmers to work with. One of the project managers took the time (about two hours!) to go over my module, reading the code until he understood it, and then asked me penetrating questions and made really good suggestions about how to change it so that it didn't just work, but was elegant and maintainable as well.

    Those two hours, and the subsequent 30 that I spent rewriting that module, cost my firm one or two thousand dollars, I suspect, on a fixed-price contract that was already over-budget. From an economic point of view, it made no sense for that review and rewrite to occur. But they made me into a much better developer both from a technical standpoint (I learned a better way to design the algorithm) and from a social standpoint (I learned a better way to make my code maintainable). I really liked being part of a company that was willing to sink that time and money into helping me improve my skills.

    So should companies have code reviews? Absolutely -- if they care about increasing the skills and maturity of their developers. If they intend for their developers' skills to stagnate, and they don't understand the value of investing in the continued education of their staff, then surely not.

    --
    A cat is no trade for integrity!
  122. Coding standards by Anonymous Coward · · Score: 0

    Having standards for coders and requiring compliance from ALL will speed things up a bit ... it helps prevent the "coding style" harping from taking valuable time.

    Our code reviews also take in account compiler efficiency/deficiency knowledge ... this can help free up a lot of time (from later optimization efforts and repeat debugging of compiler issues) and help teach newer coders about such things.

  123. It's worth it by lzdt · · Score: 0

    Email pass-around Source code management system emails code to reviewers automatically after checkin is made.

    It works much better than expected. We started on a 1st version about 2 years ago with 4 developers. After the shipment, we had a "what was good/bad, what could be better"-meeting. The bad things were the same shit as in so many projects: not documented dirty and unmaintainable code, which looked like a quick perl 1liner to check an e-mail address, but it was Java and C++! If your co-worker is touching the code parts you're interesed in or working on, you have to review his check ins and vice versa. At least it ensures, that the checked code is:
    a) Documented
    b) Doesn't contain 100+ characters long undocumented regex
    c) Doesn't look like your favorite pasta dish
    d) You know, what is going on and it makes it easier to maintain that code in the feature

    By the time we doubled the team and it seems to help. If some developer gets 2-3 "WTF?!!"-mails a day from his co-workers, he starts to think before commiting the next time..

  124. Self-Fulfilling Prophecy by theghost · · Score: 1

    Cancel the code reviews and you'll end up with more errors even though the code reviews themselves don't find that many errors. The very act of having code reviews prevents a lot of the problems that would be found in a code review because people are more careful when they know someone else is going to dig deeply into their work.

    --
    The only thing necessary for the triumph of evil is that good men do nothing.
  125. Correct by Construction by thethibs · · Score: 1

    We can't let this discussion pass without a word from Dijkstra (EWD340):

    Argument three is based on the constructive approach to the problem of program correctness. Today a usual technique is to make a program and then to test it. But: program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence. The only effective way to raise the confidence level of a program significantly is to give a convincing proof of its correctness. But one should not first make the program and then prove its correctness, because then the requirement of providing the proof would only increase the poor programmer's burden. On the contrary: the programmer should let correctness proof and program grow hand in hand. Argument three is essentially based on the following observation. If one first asks oneself what the structure of a convincing proof would be and, having found this, then constructs a program satisfying this proof's requirements, then these correctness concerns turn out to be a very effective heuristic guidance. By definition this approach is only applicable when we restrict ourselves to intellectually manageable programs, but it provides us with effective means for finding a satisfactory one among these.

    --
    I'm a Programmer. That's one level above Software Engineer and one level below Engineer.
  126. I was asking the same question by jasonofearth · · Score: 1

    My company instituted code reviews and I spent some time coming up with why they are useful: http://jasonhasalife.blogspot.com/2008/07/code-reviews-are-your-friend.html I am a huge fan, just for what can be learned. But I agree that often corporate 'code reviews' are nothing more than a boring meeting.

  127. No Review by Anonymous Coward · · Score: 0


    Think of a place where there are no code reviews. Where people hide there code and never learn from each other. Thats where I work... I say do the code reviews.

  128. scrum by luxifr · · Score: 1

    have you tried to use scrum as a style for running those development projects? i had positive experiences with that. but it's very different from the "classical" project style and it is important to follow it's rule completely - not only to take the parts you want of it - the scrum leader should have some training in his role before taking that position (there are courses you can take and even certifications to get ;)) and the product owner (mostly the customer - whoever it is) also has to comply with that as he has a quite different roll, too, compared to the classical project style.... see here http://en.wikipedia.org/wiki/Scrum_(development)

  129. Changeset based code-reviews by cmayerhofer · · Score: 1

    Code reviews have a lot of benefits, most important to find bugs during development phase and to enforce coding standards -- and they help to share knowledge about a peace of code with other team-members (called collective code ownership). But most often traditional inspection methods consumes a lot of time, hence developers are discouraged doing code reviews during their regular work. Nowadays physical code-review meetings are also a problem, because development teams are shared across offices/countries/continents, having different time-zones. The planning of review-meetings is hard or even not possible. Another problem is the delocalization of code in object-oriented and dynamic programming languages. Inheritance, dynamic binding & co. make it hard to understand an instruction, since developers use foreign classes and frameworks, and the business logic is shared across them.

    Based on our experiences from previous projects we developed a code-review tool which follows a different approach: The review item is one changeset in the revision control system. Further author/reviewer assignments are defined. The reviewer subscribes to changes (new revisions) from the author and gets a new review task if the author makes a commit to the respository. The assignments may be done in a peer to peer manner, where the developers inspect the code changes of one or more team members. Reading each others code has the consequence, that developers also learn the code from their colleagues, thus supporting collective code ownership. A more hierarchical approach would be to assign a senior developer to review the code for new or less experienced developers. The senior developer in the role of the reviewer may enforce coding standards and better code quality within the development team.

    The review-tool is called ReviewClipse (see http://www.inso.tuwien.ac.at/projects/reviewclipse/ for more information). It is free, full-integrated into Eclipse, and very easy to install and to use. All review data is stored within files, shared with the already configured repository of the Eclipse project. So there is no need to setup any server-side application, apart from the already existing versioning system.

  130. Re:Spam sig? by Omnifarious · · Score: 1

    I haven't done all that much HTML.

    And I have references for all the places I have worked who will tell you that they felt I contributed a great deal, and who will confirm that I write good code and know what I'm doing.

    Unfortunately, driver development is not something I've ever done before, and it would take me time to learn the things I'd need to know to do it.