Slashdot Mirror


Are You Too Good For Code Reviews?

theodp writes "Why do some programmers,' asks Chris Hemedinger, 'place little value on code reviews?' This apparently includes even Programming Greats like Ken 'C' Thompson, who quipped, 'we were all pretty good coders' when asked about the importance of code reviews in his work. Hemedinger, on the other hand, subscribes to the school of thought that peer code reviews are Things Everyone Should Do. Not only do reviews keep you on your toes, Hemedinger says, they also 'improve quality, ensure continuity, and keep it fresh. Who can argue against that?'"

51 of 495 comments (clear)

  1. We need more testers / QA as well by Joe_Dragon · · Score: 4, Insightful

    And some of that needs to testers who are NOT coders or people who are not mainly doing programming.

    1. Re:We need more testers / QA as well by pixelpusher220 · · Score: 2

      I would also say we need more testers who 'are' coders, just not 'the' coders of the software being tested.

      With automated testing coming along in it's depth and flexibility, implementing the tests themselves is becoming it's own version of programming.

      One of my biggest gripes is testers who don't know SQL. How do you set up your test cases without preloading the database? If you're manually entering data through the app you're testing you still need to verify that data got input correctly and that involves looking under the hood in the actual DB.

      --
      People in cars cause accidents....accidents in cars cause people :-D
    2. Re:We need more testers / QA as well by memyselfandeye · · Score: 2

      As for testing - that's a later stage in the process of development.

      Apparently by teenagers and young adults angry at the world who like nothing more than to 'test' websites with a nice little Iranian program, complete with a GUI and tutorial. They are all to happy to share their results with as many people as possible... all for free. Normally you have to pay for that:P

    3. Re:We need more testers / QA as well by arth1 · · Score: 2

      The problem with code review is that it's expensive. For someone else to go through all the code to the point that they understand all of it, they have to invest at least as much time as the coder.
      They don't, so they don't, so the code reviews become skimming for obvious flaws, which is well and good, but it isn't a code review.
      To do it properly, your code becomes twice as expensive. That's cheap, but try explaining that to a PHB.

  2. Pure Arrogance by Anonymous Coward · · Score: 2, Informative

    Anyone who is anti-code review is an arrogant snot. No one is perfect, and we all have the capacity to overlook things.

    1. Re:Pure Arrogance by JoeTalbott · · Score: 3, Insightful

      The attitude that the ends justify the means in software engineering is a problem. Software isn't a write once and forget it product nor is usually written by one person. The more people that need to work on a piece of code the more that code needs to adhere to the groups coding standards. I would highly suggest that everyone who writes code treat it as if the code is also a part of the product. Avoid shortcuts, be neat, be concise, and look at it as if you weren't the one who wrote it.

    2. Re:Pure Arrogance by Nursie · · Score: 2

      You *can* do all that stuff, it's pretty unlikely though.

      Unless you are a coding god (and I'm pretty damn good) then you occasionally make mistakes (we're all human) and you'll always benefit from the perspective of another skilled professional.

      I wouldn't work with anyone that had a serious opposition to reviews. Everyone misses something sooner or later. You are not as special as you think you are.

    3. Re:Pure Arrogance by MadKeithV · · Score: 5, Funny

      Colleague of mine used to have the following sig: "Write code as if the person who will be maintaining it is a violent psychopath who knows where you live."

    4. Re:Pure Arrogance by calzones · · Score: 2

      Code review is purposefully a politically loaded process which enables management to divide and conquer and keep wages down.

      Such processes can get hung up on stupid details when coder A's readability is better than coder B and C's, but unfortunately for A, is also not "standard" and s/he gets slammed for it and told to conform even if it makes for slightly less readable code just because it satisfies some corporate "this is how we do it and you don't question it".

      I think code reviews would be much more valuable if they were totally blind an anonymous as a means for each coder to gain insight into what others think of his/her code without knowing who is doing the critiquing, and without management ever knowing about any aspect of it.

      --
      Asking people to think is like asking them to buy you a new car
    5. Re:Pure Arrogance by DrgnDancer · · Score: 4, Interesting

      Because if it's written with an eye only towards effectiveness, and not towards standards and readability by others; then by the standards of any project larger than "A script I use to clean up my home directory" it's crappy. He's being kind of an arrogant ass about it, but his overall point is completely valid. If you quit or get run over by a bus tomorrow, and I (for a value of "I" that indicates a competent peer familiar with your company's standards and the language in question) can't pick up your project/module and continue development/support then it's not "good" code no matter well it works. That doesn't mean you can't be creative and awesome in your implementation, it just means you have to write the shit so someone else can read it; and in a pinch finish/fix it. That's what standards are for.

      --
      I don't need a million points of light, just two points of multi-mode fiber and a 10 Gig-E router.
    6. Re:Pure Arrogance by HaZardman27 · · Score: 2

      How would you rate your code in terms of ease of maintenance? I'm not trying to say what you do is wrong, but I was under the assumption that many best-practice methods were there for maintenance purposes more than achieving functionality. In my shop we do code reviews mainly so other developers know what you did, so if a problem pops up they're familiar with the changes you made. This also helps spread knowledge of the system around.

      --
      Apparently wizard is not a legitimate career path, so I chose programmer instead.
    7. Re:Pure Arrogance by Reality+Master+101 · · Score: 4, Funny

      He's being kind of an arrogant ass about it,

      I earned my Arrogant Ass Badge honestly through hard work and paying my dues, so I reserve the right to pull it out on occasion. :)

      --
      Sometimes it's best to just let stupid people be stupid.
    8. Re:Pure Arrogance by Surt · · Score: 2

      Code review can be that, but doesn't have to be. For example, at my place of work, code review results aren't documented, and can't be brought up during personnel review. The purpose of code review is quality (for us).

      --
      "Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
    9. Re:Pure Arrogance by billcopc · · Score: 2

      The problem with those "best practices" types is they usually spend 90% of their time nitpicking, and the remaining 10% copy/pasting Java patterns out of someone else's email. So yes, I agree with you, fuck 'em.

      The truth about code review is that you're not actually supposed to pick on stupid shit. The goals are usually:

      1. Make sure you didn't miss something important
      2. Make sure other people can read and understand your code

      Beyond that, who cares ? Code review isn't about belitting your colleague, it's about covering each other's ass. When dealing with an asshole reviewer, the solution is not to scrap the code review process, rather scrap the bad colleague. If the person reviewing your work starts acting like a holier-than-thou passive-aggressive jerkoff, I say whack them in the teeth with your Model M!

      --
      -Billco, Fnarg.com
    10. Re:Pure Arrogance by pthisis · · Score: 2

      The question is, are code reviews really effective? I worked on a project where we did extensive code reviews and we rarely found any real bugs. Going through a program line by line and finding a non-obvious bug is very difficult. Also, a thorough code review is also very time consuming. It takes almost as much time to review code as it does to write it in the first place. When you have four or so people reviewing every line written, your productivity for the project goes way down. In my judgment, code reviews just were not cost effective for our project.

      That's been my experience as well. We did regular code reviews for a while, but found we got more bang for the buck dedicating that time to pair programming and more developer time writing regression tests. It's not that code reviews were completely ineffectual, they're just (for most things) a very low return on the amount of time invested compared to alternatives.

      So now they're optional--occasionally when there's a particularly hairy piece of code or something the author will call for a review, and usually that makes them higher payoff.

      --
      rage, rage against the dying of the light
  3. I agree 100% by jlechem · · Score: 4, Insightful

    I have worked in places with and without code reviews. Yes code reviews can be painful especially if you work with some douchebags. But overall getting new eyeballs looking at your code often brings up things you hadn't thought about, etc. It doesn't make you or the other people bad, it's just how it is. Drop the ego and take some constructive feedback.

    --
    Hold up, wait a minute, let me put some pimpin in it
    1. Re:I agree 100% by flooey · · Score: 5, Insightful

      Yes code reviews can be painful especially if you work with some douchebags.

      I don't think the problem there is the code reviews.

    2. Re:I agree 100% by Tanktalus · · Score: 3, Interesting

      I have a huge ego. I freely admit it. I work from home because I can't fit my ego in the office doors.

      On a serious note, I prefer code reviews. From the ego-centric side, it has two major benefits: it allows my ego to show off, second it helps the less-experienced/newer developers to learn new techniques, or just learn the code, often in areas they haven't spent a lot of time looking at. That means less time helping them later. It also happens to have the side benefit that their questions can make me think about the problem harder, and not-infrequently uncover typos, thinkos, under-developed (or over-developed) features, or plain bugs. Even for us egomaniacs.

    3. Re:I agree 100% by TheRaven64 · · Score: 3, Interesting

      I've found that code reviews are most productive if you pair experienced and inexperienced coders. An experienced coder is probably writing good functional code, but may not be writing code that's easy to understand. Having code reviewed by someone less experienced helps catch things where someone new to the codebase would struggle to understand the code. This should prompt additional comments or (ideally) refactoring into a clearer form. The inexperienced developer also benefits from being forced to read and understand someone else's (hopefully good) code. In the other direction, the inexperienced developer gets helpful feedback on their design and techniques.

      Code reviews done by someone with a similar skill level tend to be a waste of time. They'd typically implement things in more or less the same way, so they either skip over things and don't give much feedback or they're really pedantic but not very helpful.

      --
      I am TheRaven on Soylent News
  4. There's a point when... by blahplusplus · · Score: 2

    ... code is good enough.

    There are times when code reviews make sense and times where they don't, having the wisdom to know the difference is key.

    1. Re:There's a point when... by ArsonSmith · · Score: 2

      Ohh, and it does what the customer expected...or was that part optional?

      --
      Paying taxes to buy civilization is like paying a hooker to buy love.
  5. Welcome to the industry, Chris. by xxxJonBoyxxx · · Score: 3

    Perhaps peer code reviews were less important 30 years ago. The constraints around running code were much tighter. There were fewer layers in the stack where bugs could lurk. Memory was scarce, instruction sets were limited. Computer applications were like my 1973 AMC Gremlin: fewer moving parts, so it was easier to see which parts weren't working correctly and predict when they would fail.

    Welcome to the industry, Chris. This might have been the funniest thing I read all week.

  6. I'm not too good for code reviews by jeff4747 · · Score: 5, Insightful

    I'm too busy for code reviews.

    Development schedules are almost always ridiculously compressed. There's no time in the schedule for code reviews. Just like there's no time for thorough testing.

    But the software only has to be 'good enough' for people to buy it, so there's no ammunition for developers to use to get a better schedule.

    1. Re:I'm not too good for code reviews by alexo · · Score: 5, Funny

      Which is pretty much why I gave up on computer science and am moving into Geology instead.

      I heard that Geological processes have pretty relaxed schedules.

  7. Re:It's a cost/benefit thing by NorthWestFLNative · · Score: 2

    Even good coders make mistakes. There can be various reasons for this, maybe someone was suffering from insomnia the night before and their mental processing is slower. Maybe they were working on a part of a project and there are integration issues in their code between a part of the project that they were not as familiar with.

    Not every issue in code can be found by peer review, and not every issue in code can be found by testing. A good team has a combination of good coders, good peer reviews, and good testing. You need all of that (and more) for a good project. Good coders are not everything. Nor should they have an ego about their code. A good coder should realize that everybody makes mistakes, even themselves.

  8. Obvious answer is obvious by GreyWolf3000 · · Score: 2

    Because code reviews end up being an enabler for OCD coworkers to tell me how to indent.

    --
    Slashdot: Where people pretend to be twice as smart as they really are by behaving like children.
    1. Re:Obvious answer is obvious by syntap · · Score: 2

      Because code reviews end up being an enabler for OCD coworkers to tell me how to indent.

      This.

      Conflicts in particular coding styles can easily derail a code review that is supposed to review for security and bugs into how something could be made minimally more efficient while eliminating overall code readability/maintainability. And there is always the guy who never comments his code, the peer reviewers take time to read through it trying to figure out what he is doing, provide comments and include a note to please comment code, and it never happens.

      As long as a team has a documented set of coding standards (naming conventions and such) I'm happy to try it. A bug or two or security issues found during a review that don't make it into production pays for itself easily. But code reviews that devolve into coding philosophy debates aren't code reviews anymore.

  9. In the perfect world maybe .... by johnlcallaway · · Score: 2

    If I had all the time in the world, I would test more thoroughly, and do more post-production audits too.

    But I don't have all the time in the world, so I do what I can given the time that I've been given to get work done. I consult my peers often enough that reviewing all the code all the time is a waste of both my time and theirs.

    It shouldn't be necessary to review every scrap of code. I think I've written enough that I have the basics down pretty well. And when I get into new subjects, I always talk it over with someone to see if we can find an optimal way of doing something.

    If two people have already agreed on the best way to code a specific task, having them review each others work all the time is a waste of time.

    --
    I rarely read replies, it's my opinion and if you thought about your opinion a little more, I'm OK with that.
  10. The problem is poor developers... by rtilghman · · Score: 4, Insightful

    The problem is that the need for code reviews is driven by lax, sloppy developers who don't see regression testing as a requirement, and who foist crappy, untested code that, in many cases, they haven't even tested.

    As a consulting exec (experience side) who oversees software delivery I can't even begin to express the stunning crap that I see developers submit for "qa/review". Crap that doesn't even WORK correctly in the first place is submitted for testing, with the QA feedback often "Does not work". Aside from the hours of UE and QA resources this burns with useless testing, it highlights what I think is both an increasing lack of accountability and a lack of professionalism within the development community in general.

    What's driving this I have no idea... less formal CS training? Looser languages? Web-centric apps? Lower end standards? Higher demand = more crappy resources? Whatever it is I'm seeing it everywhere, and it's driving me nuts. The lack of an appreciate for regression testing is absolutely insane... code reviews are just symptomatic of a larger problem, which is a lack of quality and skill.

    -rt

  11. Code review as a method for knowledge passing by Anonymous Coward · · Score: 4, Insightful

    I tend to use code reviews as a method for showing other team members the work that I have done so they will know about the changes. I work with a large number of geographically disperse people and having 1:1 conversations about every little change can be tiresome and wasteful. Code reviews are an excellent way to get around this problem.

    Another bonus for code reviews, along the same lines - is in teaching people new to a platform about the kinds of bugs to expect when working on the platform.

    It also keeps me honest, did I just add a debug, or do I also need to add trace? If I forgot the trace, code review will pick that up.

  12. "formal" code reviews: a waste of time by spectro · · Score: 2

    Having another pair of eyes on your code is a very good idea but this whole concept of everybody getting together and put somebody's work to shame is bad for team dynamics and a waste of time.

    I rather have a team dynamic where any developer can pick up a task involving work on somebody else's code, this way code reviews just happen naturally.

    --
    HTML is obsolete. It's time for a new, simpler and richer markup language.
  13. this by DeadCatX2 · · Score: 2

    In the time we all spend reviewing my code, we could have each fixed separate bugs in the software or completed a new feature. Not only does the code review practically halve my productivity, it halves everyone else's.

    --
    :(){ :|:& };:
    1. Re:this by Omnifarious · · Score: 4, Informative

      I've caught bugs in code review that would never in a million years have been caught by testing. The customer would've encountered them sporadically, and in situations in which they'd come to rely on the broken behavior working implicitly. The would've submitted a bug report and we would've been unable to replicate the problem in house. The customer's opinion of us would be lowered, and we'd have all these bug reports in our system that nobody could figure out.

      That is, until someone reviewed the code and discovered the bug.

      So, basically what you're doing is robbing Peter to pay Paul. By not doing the reviews you end up with less time in the long run, not more.

    2. Re:this by Omnifarious · · Score: 3, Insightful

      My goal, as a developer, is to make sure QA never catches any bugs. When they find a bug, I'm embarrassed, as I should be. Developers who have a purposeful strategy of waiting for QA to find their bugs should be fired.

    3. Re:this by sconeu · · Score: 2

      And it's been shown that the earlier a defect is found, the cheaper it is to correct.

      --
      General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
    4. Re:this by drpentode · · Score: 3, Insightful

      Finding a bug in your own code costs one of unit of work. QA finding a bug in your work costs 10 units of work. Having a customer find a bug in your code costs 100 units of work. Doing code reviews increases efficiency. Plus, you get to both teach and learn from your peers.

    5. Re:this by Anonymous Coward · · Score: 2, Insightful

      Your statement is true, if you care about the end user. If you just care about getting paid by finishing your work on time so that its good enough to sell the product and make money, then your statement is no longer true.

      If the company creating the product does care not about long term satisfaction, they may just want to ship a "good enough" product that people will buy. In that case code reviews are out the window. I'm pretty sure that's what jeff4747 was getting at.

      It's unfortunate that any company thinks that way, but it is the case pretty often.

    6. Re:this by Anonymous Coward · · Score: 2, Insightful

      And no matter how many times you tell management this, they will continue to prefer to pay the higher cost later.

    7. Re:this by rmstar · · Score: 3, Insightful

      Finding a bug in your own code costs one of unit of work. QA finding a bug in your work costs 10 units of work. Having a customer find a bug in your code costs 100 units of work. Doing code reviews increases efficiency. Plus, you get to both teach and learn from your peers.

      That's all nice and dandy, but the problem is that in reality it still makes sense sometimes to produce and sell buggy software. This is so for a variety of reasons. Amongst them the fact that actually pulling off a business is a very multifacetic thing, and the product is only one of many aspects. In many cases, the cost of making a good product is simply prohibitive when viewed in the grand scheme of things.

      Reality is messy.

  14. Re:automated testing can let stuff fail but still by pixelpusher220 · · Score: 3, Insightful

    automated testing is primarily for regression testing anyway. GUI / user experience 'testing' is usually after that point, since 'GUI' is just the interface and not the back end logic. Working but looking bad is inherently preferable to looking good but not working....

    --
    People in cars cause accidents....accidents in cars cause people :-D
  15. ReviewBoard by Mr.+McGibby · · Score: 2

    If you use some software, then the process is MUCH easier. http://www.reviewboard.org/

    --
    Mad Software: Rantings on Developing So
  16. Good, the Bad and the Ugly by npsimons · · Score: 2

    I *wish* I had code reviews! Granted, I would also like to choose my reviewers, or at least set a minimum bar ("first, write the FizzBuzz program in the language that the code we are reviewing was written in"). I can understand not wanting to subject yourself to people who really shouldn't be reviewing code (one comic I saw had a "reviewer" stating "all those curly brackets and semicolons really ruin the feng shui of the code"). And maybe some (very rare) people don't need code reviews (I suspect that most people would get more out of reviewing Ken Thompson's code than Ken Thompson would get in return; in other words, learn from the greats). But most code seriously needs to be reviewed. Just drop the ego, get over yourself, and set some standards for reviewers and coding style, then review.

  17. Test at earliest possible moment by perpenso · · Score: 3, Insightful

    As for testing - that's a later stage in the process of development.

    Testing and code reviews should occur at the earliest possible moment and be integrated throughout development. Bugs cost less when they are found earlier.

  18. Samba slowly moving to mandatory code reviews. by Jeremy+Allison+-+Sam · · Score: 2

    We already have this for all release streams. Only one person (Karolin) the release manager can commit to a release stream - all other changes have to be associated with an open bug report and go through at least one code review before going in.

    Master branch is still more open for rapid development, but we're moving in the direction of more and more code reviews.

    I don't like doing code reviews, but I like having my code reviewed as other people find my bugs :-).

    Jeremy.

  19. If code reviews are good... by hsthompson69 · · Score: 2

    ...then continuous code reviews are great. Keep two sets of eyeballs on the code *as you write it*. Yes, the antisocial archetype hates pair programming, but it simply works, even if it is uncomfortable (as code reviews often are).

    The real problem with formal code reviews is that all too often, the reviewers are so distant from the day-to-day issues in the code they can't to much more than give superficial suggestions ("I don't like how you named this variable", or "we need more comments here"). Arguably, to do a truly thorough code review, you'd have to spend *at least as much* time prepping for the code review as it took for the coder to put it together in the first place...quite probably several times more.

    If they really wanted to make them more useful, though, code reviews should be conducted on running code, and any review item should be immediately fixed in the code, and the whole regression suite of tests run in front of all the reviewers.

  20. Shitty code can come up with the right answer by perpenso · · Score: 2

    I can't figure out why you jump to the conclusion that my code is 'crappy'.

    Perhaps you are the exception, but I (25 years exp) agree with the other poster in a general sense. When someone says "I want my code to be judged on it's output / functionality instead of how it is written" that is a big warning sign. People who make such statements are often those who slap together mediocre code as fast as they can, with only narrow use in mind ... code that in the long term tends to be difficult to maintain, buggy beyond the original narrow use envisioned, and difficult to adapt for related uses. Again, perhaps you are the exception but there is a strong correlation between mediocre code and the perspective offered.

    Similar to the above, there is a high correlation with delusional overconfidence and statements like "I've never come to appreciate something as ridiculous as 'company-wide' ANYTHING. You don't hire me for my ability to conform!". I've had the pleasure of working on teams with incredibly talented and experienced professionals and their attitude is quite the opposite. For example they understood the need to have an agreed upon coding standard to make things more readable to the group, to minimize diffs that can be bloated by personal formatting tastes, etc. Personally preferences were prevalent when coming up with the coding standard for the team, blood was nearly spilled :-), but once negotiated and agreed upon everyone went with it. As for code reviews these people liked them. Highly talented people often like to learn from other highly talented people. Again, perhaps you are the exception, but the attitude offered is more commonly associated with those of lesser talents.

    In short, shitty code can come up with the right answer. So arguing that your code comes up with the right answer is not necessarily informative. Once again, having not reviewed your code I can't speak towards your specific talents. I think myself and the other poster are saying that your comments seem to fit a pattern that we and many others have seen before. If you are truly an exception you might want to rephrase your comments to not fit this well established pattern.

  21. I can't think w/ someone looking over my shoulder by moorster · · Score: 2

    It just doesn't work to have two guys crammed in a cubicle huddled around a monitor. It's just like the human eye that sees by quickly moving about. The person who is 'driving' is the only one with any ability to understand the code. The other person quickly zones out. Meanwhile, the person who is driving gets self-conscious about how fast/slow he's going so he stops thinking about the code too. If either person says anything out loud it completely destroys the other's train of thought. It devolves into a dysfunctional group-think where each person says "I'm OK with it if you are...". For me it works much better to monitor the SVN commits and take my time to look at every line of code and work through it at my own pace.

  22. Dogma by lolococo · · Score: 2

    I've read a lot of posts in this thread with "you should", "you must", "you have to", you're not", "absolutely" etc. This all sounds like dogma to me, and as such, I view it with a suspicious eye.

    C'mon guys, with all the technologies and programming languages, there's an infinity of things that be done very well. Surely, within that infinity, there's room for people who think differently?

    In my experience, sticking to any kind of dogma or absolute is one major factor of failures in software development. Keep your mind and your options open. Be ready to adopt code reviews and to abandon them. Best practices are indeed just that. They're not the only practices, and more often than not they are in reality good practices. There's no one-size fits-all, not in the software industry, so please let's calm down and consider things outside our comfort zone, they have merit too.

  23. Nobody wants code reviews by Sarusa · · Score: 2

    Rather, almost everyone loves the idea ('oh yeah, we should do that'), but as soon as you attach the time/budget cost to it they decide it wasn't that important anyhow.

    And they are extremely time intensive. Coders need to walk through the code line by line in advance for the review to be useful, then there's the drawn out meeting itself, and usually a manager wants to be there which adds more budget and slows things down with useless questions, then the writeup.

    Ah, you say, but it will save time in the long run, because it takes less time to track the bugs down now rather than one at a time later. But (almost) nobody is willing to trade possible future time loss against significant right now time loss.

  24. It depends on who's doing the reviewing ... by golodh · · Score: 2
    Whether a code review is useful all depends on who's doing it.

    A nice caricature can be found here: http://www.jsquared.co.uk/jennyl/verity.htm

    Don't believe that his sort of response during code reviews is all that uncommon.