Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

What is code review? (Java code review)

Thread view: 
www - 10 May 2007 15:30 GMT
Hi,

My boss just told me a concept I didn't know. (I am middle level Java
programmer.) -- "code review".

According to what I heard, "code review" is somebody reads the thousands
lines of code written by other person and try to find if there are some
errors (logic errors, I guess, since the code at least can be compiled
and run).

I feel this is crazy!!! Since the reviewer has to "read" the original
code author's mind and make sure the code does what the author wants and
no hidden surprises! How this could be possible?! This would be
extremely time consuming and nobody knows better about the code than the
author.

My boss says this is very common practice in software engineer development.

Is this true? Or my understanding from my boss is wrong?
Stefan Ram - 10 May 2007 15:47 GMT
>According to what I heard, "code review" is somebody reads the thousands

 Ever heard of search engines or Wikipedia?
David Gillen - 10 May 2007 15:59 GMT
www said:
> Is this true? Or my understanding from my boss is wrong?

Why not ask your boss to clarify exactly what he means. Often management types
use terms they've picked up without having a clue to what they mean at all.

D.
Signature

Fermat was right.

Arne Vajhøj - 11 May 2007 01:39 GMT
> www said:
>> Is this true? Or my understanding from my boss is wrong?
>
> Why not ask your boss to clarify exactly what he means. Often management types
> use terms they've picked up without having a clue to what they mean at all.

Boss: I think we should use an SQLServer.
Employee: What colour ?
Boss: Blue - they have most RAM.

(I think it is from an old Dilbert stripe)

Arne
Andy Dingley - 14 May 2007 16:26 GMT
> Boss: I think we should use an SQLServer.
> Employee: What colour ?
> Boss: Blue - they have most RAM.

Look up "pointy haired boss" on Wikipedia. This joke is more subtle
than you realise.
Patricia Shanahan - 10 May 2007 16:02 GMT
> Hi,
>
[quoted text clipped - 15 lines]
>
> Is this true? Or my understanding from my boss is wrong?

I've only participated in informal code reviews, in which the objective
is not to look at every line, but to find the lines that should be
looked at.

There is often a mix of two high level objectives:

1. General search for errors.

2. Verification of code quality.

Both aspects should focus on problems that cannot be detected by the
software development tools.

For example, I would spend far more time on synchronization and
multi-threading issues than on aspects where bugs would be found in the
first few minutes of testing. There is no point in spending human time
checking whether the indentation is correct, but no computer program can
evaluate whether identifiers are meaningful.

Remember that readability is an important aspect of code quality. Code
that can only be maintained by the author is of limited value in most
organizations. I don't think there is any automated test for readability
that works anywhere near as well as seeing what happens when a
non-author programmer tries to read the code.

This is a good time to review your documentation imagining another
programmer trying to understand your code.

Patricia
TobiMc3@gmail.com - 11 May 2007 12:59 GMT
I 2nd that.  It sounds like your boss picked up the term somewhere.

I agree with Patricia's comments.  Additionally, code reviews can help
you learn other easier ways of accomplishing things-because your peers
can give you suggestions on technique.

Tobi
Daniel Pitts - 10 May 2007 16:05 GMT
> Hi,
>
[quoted text clipped - 5 lines]
> errors (logic errors, I guess, since the code at least can be compiled
> and run).
The code review is more about verifying that the design is correct,
but it does often find logic errors as well.

> I feel this is crazy!!! Since the reviewer has to "read" the original
> code author's mind and make sure the code does what the author wants and
> no hidden surprises! How this could be possible?! This would be
> extremely time consuming and nobody knows better about the code than the
> author.

That's not necessarily true.  An author might have a good feel for the
code at the immediate moment, but what happens down the road a year or
two when you haven't thought of it for that long... You'll have to
time travel and read your own mind... But not really, if you write
well designed code, the code will convey your intentions (such as by
method name, variable name, etc...) and what you actually did (its not
difficult to step through a method mentally).  A good code reviewer
would ask you questions like "You named this method getBars, when if
fact what you seem to do is get wibbles. Is it named appropriately?"

> My boss says this is very common practice in software engineer development.
>
> Is this true? Or my understanding from my boss is wrong?
Code reviews are common practice and a good idea.  You're boss is
correct, but your thoughts are not.

I wouldn't call yourself a middle level Java programmer quite yet.  I
consider middle level someone who can convey meaning in there symbol
names, as well as someone who knows what a code review is.
alexandre_paterson@yahoo.fr - 10 May 2007 16:55 GMT
> According to what I heard, "code review" is somebody reads the thousands
> lines of code written by other person and try to find if there are some
> errors (logic errors, I guess, since the code at least can be compiled
> and run).

It's not just about parsing thousands of line of code but, yup, you
can do that.  And it's *crazy* what an "OK" programmer will find in
code produced by some not-so-OK-yet programmer.

I've done "dumb eye ball searching" code review (literally reading
lots of lines of codes one by one) and what you find is usually
pathetic.

I've been working for a startup where a programmer had a "working"
program in which a method had 2000 lines of code.

2000 lines of nested "if / then / else" with basically the same
code copy/pasted and nested and nested several times.

(this "method" ended up being rewritten in about 5 methods /
130 lines of codes)

Crazy.

And that guy had a diploma and passed the interview...

Worst I've seen was probably in some source code
for a medical appliance where the manipulation of
dates showed a complete non-understanding of both
programming and the API available.

> I feel this is crazy!!! Since the reviewer has to "read" the original
> code author's mind and make sure the code does what the author wants and
> no hidden surprises! How this could be possible?!

Well for a start the reviewer will see if the code is readable
at all.  If only the author can read what some piece of code
does then the company is in big trouble.

Note that I won't call names but there's a specific
part of the programming community that do use that
age old trick of "writing unreadable code to keep their
job".

And it appears quite obviously when doing code
reviews.  Companies don't need such jerks.

> ... and nobody knows better about the code than the
> author.

But lots of programmers knows for sure a better
way to do what the code of that author does.

Been there, done that.
Oliver Wong - 10 May 2007 17:04 GMT
[anecdote about a really bad programmer]

> And that guy had a diploma and passed the interview...

   IMHO, a diploma doesn't really mean anything. GPA is pretty
meaningless to me too. If I have a candidate fresh out of university, I'd
be more interested in seeing a list of classes she took (did she take a
compiler course? a course on AI? etc.), and then I'd ask her during the
interview about those classes (what projects did she work on for those
courses?)

   - Oliver
Oliver Wong - 10 May 2007 16:58 GMT
> According to what I heard, "code review" is somebody reads the thousands
> lines of code written by other person and try to find if there are some
[quoted text clipped - 6 lines]
> extremely time consuming and nobody knows better about the code than the
> author.

   If the review has to read minds, and this is impossible given the
level of documentation and choice of identifiers in your code, then your
code is probably poorly written.

   Consider the following code snippet:

public int a(int b) {
 return b;
}

   Does this do what the author intended? Are there any hidden surprises?
It's impossible to tell, because the author did not write any
documentation, and chose meaningless identifier names. Contrast with this
code:

public int hashInt(int intToHash) {
 /*
  * Implementation is just to return the same
  * int. This is a perfect hash.
  */
 return intToHash;
}

   Now, thanks the the name of the identifiers, and the comments, we can
guess what the author was trying to do, and check that it does in fact do
what the author intended.

   Code reviews correctly would flag the first example as needing to be
rewritten.

> My boss says this is very common practice in software engineer
> development.
>
> Is this true? Or my understanding from my boss is wrong?

   It's common. I don't know about "very" common, but it's common enough
that I'd expect someone referring to themselves as a "middle level
programmer" (whether Java or some other language) to know what the term
"code review" refers to if I brought it up.

   As an aside, to help re-assess your self-evaluation, I'd also expect
someone referring to themselves as a middle level programmer to be
familiar with the following terms. If you're not familiar with them, you
may wish to do some more reading.

   * Design patterns
   * Extreme Programming
   * Test Driven Development
   * Unit Testing
   * Black Box Testing
   * Model View Controller
   * Singleton
   * Source Version Control
   * Pair Programming
   * KISS
   * UML
   * Class Diagram
   * Sequence Diagram

   Note that for the terms that refer to methodologies, I don't expect a
middle level programmer to actually *practice* all of the above
methodologies, but rather that they should be familiar with what the terms
refer to.

   - Oliver
rossum - 10 May 2007 18:01 GMT
>Hi,
>
[quoted text clipped - 15 lines]
>
>Is this true? Or my understanding from my boss is wrong?
Think of a code review as an opportunity for you to improve your
programming skills.  Your boss is letting you take some of your
colleagues time to comment on your code.  That lets you pick their
brains as to how you could code better.  How much would it cost you to
hire a consultant to look at your code and suggest ways to improve it?

rossum
Sherm Pendley - 10 May 2007 18:32 GMT
> I feel this is crazy!!! Since the reviewer has to "read" the original
> code author's mind and make sure the code does what the author wants
> and no hidden surprises!

If ESP is required to divine the code's purpose, that's already the first
sign of a problem. There should be:

   a. A written specification
   b. Unit tests
   c. Comments within the code itself

Furthermore, it shouldn't be delayed until thousands of lines of code have
already been written. It's an ongoing, continuous process, not a checklist
item that must be checked once before shipping. In "pair programming", this
actually involves two programmers sitting in front of one keyboard, working
together and reviewing one another's code.

> How this could be possible?! This would be
> extremely time consuming and nobody knows better about the code than
> the author.

What if the author gets hit by a meteor? Code *must* be readable and main-
tainable to be useful. If the reviewer can't read the code, it fails the
code review.

> My boss says this is very common practice in software engineer development.

Your boss is correct.

sherm--

Signature

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Patricia Shanahan - 10 May 2007 19:37 GMT
>> I feel this is crazy!!! Since the reviewer has to "read" the original
>> code author's mind and make sure the code does what the author wants
[quoted text clipped - 6 lines]
>     b. Unit tests
>     c. Comments within the code itself

d. The non-comment code

Essentially, all code should be treated as communication to two
audiences with very different needs. The compiler just cares that an
identifier follows the language syntax, but "xyzzy" is just as good as
"columnNumber". The other audience is programmers, including the
author's own future self, three years later after writing a few thousand
lines more on other projects.

In addition to identifier selection, there are often multiple ways of
coding something, some of which make intent and meaning clearer than others.

Looking on the optimistic side, suppose the code is really well written,
and would be easy for another programmer to maintain. The code review is
the chance for the boss to get the good news.

Patricia
szewong@gmail.com - 10 May 2007 19:51 GMT
> >> I feel this is crazy!!! Since the reviewer has to "read" the original
> >> code author's mind and make sure the code does what the author wants
[quoted text clipped - 24 lines]
>
> Patricia

I've been an Architect for many years and code review is always
something that is difficult to do right. I have tried from formal code
review meetings to reviewing CVS check-ins daily, to my latest 'pair
and monitor' approach. Basically as many have pointed out, this is a
necessary process to ensure the right design, coding partice are in
place. Code reveiw is supposed to make the team more aware of what one
another is doing and improve code quality as a whole.

Anyway, I'm always for light process. And that is what right now I'm
heavily relying on 'pair and montior'. By pairing developers, you have
a higher chance of having better documented code. We then have one of
two team members who's sole responsibility is to monitor everything
that goes into CVS and flag anything that disagree with our
development handbook. So far this is a low impact approach that seem
to be working.

Sze Wong
Zerion Consulting
http://www.zerionconsulting.com
See my blog at: http://szewong.com
Ed Kirwan - 11 May 2007 11:27 GMT
...

> Sze Wong
> Zerion Consulting
> http://www.zerionconsulting.com
> See my blog at: http://szewong.com

Sze, I notice you've password protected all your blog entries.

An interesting strategy ...

.ed

Signature

www.EdmundKirwan.com - Home of The Fractal Class Composition.

Download Fractality, free Java code analyzer:
www.EdmundKirwan.com/servlet/fractal/frac-page130.html

Karl Uppiano - 15 May 2007 03:35 GMT
> Anyway, I'm always for light process. And that is what right now I'm
> heavily relying on 'pair and montior'. By pairing developers, you have
[quoted text clipped - 3 lines]
> development handbook. So far this is a low impact approach that seem
> to be working.

One of the most productive projects I ever worked on was one in which the
developers swapped coding and JUnit tasks. You have to understand the code
pretty well to write the JUnits. And the second set of eyes gave us a
tremendous insight into problems, optimizations, clarifications, naming and
so on.

We got continuous code reviews almost for free, since 100% JUnit coverage
was a project goal (I think we settled for somewhat less than 100% in the
end, but it was a noble goal).
Eric Sosman - 10 May 2007 20:41 GMT
Patricia Shanahan wrote On 05/10/07 14:37,:

>>>I feel this is crazy!!! Since the reviewer has to "read" the original
>>>code author's mind and make sure the code does what the author wants
[quoted text clipped - 22 lines]
> and would be easy for another programmer to maintain. The code review is
> the chance for the boss to get the good news.

   Another benefit of code review is the exchange of
ideas between author(s) and reviewer(s).  "What you've
got will work, but if you used two BitSets and a HashMap
you could avoid most of the database queries."  "This is
fine, but it would be easier to internationalize (should
we ever decide to) if it were refactored thusly: ..."

   Or even "Hey, this is slick.  Y'know, in a review
last week we saw some code where Zaphod solved a problem
a lot like this one, but this is better.  If you'd make
changes X,Y,Z we could use your code in his project, too."

   The main thing is to approach a review -- in either
role! -- with a peculiar mixture of pride and humility,
not with an amalgam of arrogance and apprehension.

Signature

Eric.Sosman@sun.com

Richard Reynolds - 10 May 2007 20:17 GMT
> Hi,
>
[quoted text clipped - 15 lines]
>
> Is this true? Or my understanding from my boss is wrong?

I find that you've never heard of code reviews very strange, I've never
worked anywhere where they didn't do them in one form or another, sometimes
very useful, depends how good your process is.
If you think reading someone else's code is crazy, how do you manage to
maintain any code? Do you rewrite everything you do from scratch!?
www - 10 May 2007 20:51 GMT
Thank you all for your replies. Now, I have learned a lot about "code
review" and software testing.

Now, I hope to switch the topic to a different one, but related:

I have found that "code review" or "software testing" is really easy to
get into trouble with the team members, no matter how polite or careful
you are. Why? Because:

Nobody likes his code to be found has "error". It is completely OK for
the systems to be found behave incorrectly one or two years later,
because it is different branch people (or even different company) to
debug and maintain the software. Even they found that bug, nobody will
pay attention to who was the original author of that Java class and that
person should be blamed. But it will be very bad in the same team, when
he just finished his code and tell him that something is not right. He
will say "Thank you" to me. But I will never expect good mood between
him and me.

So, no matter what textbook about program testing says, ("non-biased",
"thoroughly", ....), practically, I would just pretend I have reviewed
the code, I have tested it and let the program go. (I will point out one
or two extremely light errors to the author.) The author will get what
he wants, fame or whatever, I get what I want: no enemy and keep my job.
Sherm Pendley - 10 May 2007 21:44 GMT
> So, no matter what textbook about program testing says, ("non-biased",
> "thoroughly", ....), practically, I would just pretend I have reviewed
> the code, I have tested it and let the program go. (I will point out
> one or two extremely light errors to the author.) The author will get
> what he wants, fame or whatever, I get what I want: no enemy and keep
> my job.

If you think that habit will ensure job security, think again. If I had
an employee who was doing what you describe here, I'd fire him on the spot.

Do your job and review the code thoroughly - the "my code is perfect" prima
donnas won't be there long enough to make your life difficult anyway.

sherm--

Signature

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Daniel Dyer - 10 May 2007 21:50 GMT
> Thank you all for your replies. Now, I have learned a lot about "code  
> review" and software testing.
[quoted text clipped - 14 lines]
> will say "Thank you" to me. But I will never expect good mood between  
> him and me.

It can be a delicate situation, and it would depend to some extent on how  
you go about it.  Everybody needs to understand that the reviews are for  
everybody's benefit and that everybody makes mistakes, even the guru  
programmers.  Perhaps if everybody gets a chance to review somebody else's  
code it won't be so bad.  Then at least everybody experiences it from both  
sides.  If the junior programmers aren't ready to conduct a review by  
themselves, maybe they could assist a more senior colleague.  This has the  
advantage of helping them to learn from other people's mistakes as well as  
their own.  I think it also helps if the reviewer is somebody who is  
respected by the author of the code.  Also, the wounded pride that comes  
from somebody finding problems in your code can be good motivation to  
improve things for next time.

Steve McConnell has a section on formal reviews in his book, "Code  
Complete".  He also devotes a chapter to "Personal Character", which  
addresses the issue that you have just raised:

"The people who are best at programming are the people who realize how  
small their brains are. They are humble. The people who are the worst at  
programming are the people who refuse to accept the fact that their brains  
aren't equal to the task. Their egos keep them from being great  
programmers. The more you learn to compensate for your small brain, the  
better a programmer you'll be. The more humble you are, the faster you'll  
improve."

> So, no matter what textbook about program testing says, ("non-biased",  
> "thoroughly", ....), practically, I would just pretend I have reviewed  
> the code, I have tested it and let the program go. (I will point out one  
> or two extremely light errors to the author.) The author will get what  
> he wants, fame or whatever, I get what I want: no enemy and keep my job.

In the long run that's counter-productive.  Eventually you'll have to  
maintain that code.  It's better to catch the bad bits early before they  
get out of control.  If you spot problems with a colleague's code, just  
let them know in private - you don't have to get up in front of the whole  
team at your next meeting and declare that person to be incompetent.  
Alternatively, if you don't want to single anybody out, you can raise  
general problems in front of the whole team without referring to specific  
examples.  E.g. "I've noticed a few places where we've been over-riding  
equals without over-riding hashcode - this could cause us problems  
because...."  Then you've raised the issue and anybody who was ignorant of  
the implications will now know better without any embarrassment.

Dan.

Signature

Daniel Dyer
https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java

Oliver Wong - 10 May 2007 21:52 GMT
> I have found that "code review" or "software testing" is really easy to
> get into trouble with the team members, no matter how polite or careful
[quoted text clipped - 9 lines]
> will say "Thank you" to me. But I will never expect good mood between
> him and me.

   That's a tricky situation to be in. For what it's worth, where I work,
we feel pretty comfortable about pointing out mistakes to each other. E.g.
"You forgot a null check here", "I think it'd be clearer if you renamed
the method to 'getIntHash', rather than 'getHashInt', etc."

   We seem to realize that everyone makes mistakes, so that such
corrections are not so embarassing as to cause tension in the worksplace.
I realize, though, that not everybody is like that, and you don't always
get to choose who your coworkers are.

   Pair programming makes this a bit easier, because the feedback is
immediate, and we may console ourselves with "Well, even if he wasn't
around, I probably would have spotted that NullPointer bug eventually
anyway, given a few more seconds of staring at the code...", and the code
can be credited to both of you, so that you both share in its quality (and
its blame). But again, your boss may not be so keen on the idea of pair
programming.

   I hope, for your sake, that you're simply underestimating your
coworkers' maturity.

> So, no matter what textbook about program testing says, ("non-biased",
> "thoroughly", ....), practically, I would just pretend I have reviewed
> the code, I have tested it and let the program go. (I will point out one
> or two extremely light errors to the author.) The author will get what
> he wants, fame or whatever, I get what I want: no enemy and keep my job.

   I don't think anyone decides to become a programmer because they think
that'll make them famous. "Microsoft Word" is a very famous application.
Who wrote it? I have no idea. Google is a very famous web application. Who
wrote that? I don't have a clue. In fact, I suspect in both cases it
wasn't one specific person, but a team of people, further diluting the
fame of any one programmer within that team.

   I'll also point out that if the boss gives you the task of review a
piece of code, and later on, a bug is found in that piece of code, it will
be both the fault of the original author of that code for writing the bug,
and your fault for not having caught it as reviewer. If this happens once
or twice, it's not a big deal (bugs slip through; that's just how software
development is), but if the code you review is consistently buggy, your
boss may feel you are not very competent in terms of code reviewing, and
that may have adverse effects in the future.

   - Oliver
Patricia Shanahan - 10 May 2007 22:10 GMT
>> I have found that "code review" or "software testing" is really easy to
>> get into trouble with the team members, no matter how polite or careful
[quoted text clipped - 14 lines]
> "You forgot a null check here", "I think it'd be clearer if you renamed
> the method to 'getIntHash', rather than 'getHashInt', etc."
...

I don't know whether I've just been lucky, but for the 32 years I spent
in the computer industry, I was always in teams that had the "We are in
this together, and all want it to work" attitude.

Patricia
Eric Sosman - 11 May 2007 03:28 GMT
>>> I have found that "code review" or "software testing" is really easy
>>> to get into trouble with the team members, no matter how polite or
[quoted text clipped - 20 lines]
> in the computer industry, I was always in teams that had the "We are in
> this together, and all want it to work" attitude.

    A decade or so ago there was a movement called "egoless
programming," which encouraged programmers to write and fix
and improve "the" code rather than "my" code.  I never worked
at a shop where this notion was enshrined in formal procedure,
but the best programmers I worked with all shared the notion
that the code was "ours" and not "mine."

    I think it's a healthy attitude, and a differentiator
between professionals and hobbyists.

Signature

Eric Sosman
esosman@acm-dot-org.invalid

Brian Raven - 11 May 2007 21:32 GMT
>>>> I have found that "code review" or "software testing" is really
>>>> easy to get into trouble with the team members, no matter how
[quoted text clipped - 30 lines]
>     I think it's a healthy attitude, and a differentiator
> between professionals and hobbyists.

I recall first reading about egoless programming in Weinberg's
Psychology of Computer programming which, according to a quick google,
was first published in 1971. I agree its a healthy attitude. A key
point to remember with code/design reviews, I find, is to not take it
personally, whether you are reviewer or reviewee.

Signature

Brian Raven

Richard F.L.R.Snashall - 10 May 2007 22:02 GMT
> Nobody likes his code to be found has "error". It is completely OK for
> the systems to be found behave incorrectly one or two years later,
[quoted text clipped - 5 lines]
> will say "Thank you" to me. But I will never expect good mood between
> him and me.

Don't you want to know your code will work correctly?  To me, that
has always been paramount.  Who cares how it got that way?
Richard Reynolds - 10 May 2007 22:32 GMT
> Thank you all for your replies. Now, I have learned a lot about "code
> review" and software testing.
[quoted text clipped - 19 lines]
> two extremely light errors to the author.) The author will get what he
> wants, fame or whatever, I get what I want: no enemy and keep my job.

My god! where do you work? Nazi Germany?
Harald Kästel-Baumgartner - 11 May 2007 10:23 GMT
"Richard Reynolds" <richiereynolds@ntlworld.com>

> My god! where do you work? Nazi Germany?

Oh, you missed a lot the last 60 years.

A special test for you: Who is Prime Minister?
(  )   Blair
(  )   Churchill.

Do you know it?
Lew - 11 May 2007 13:22 GMT
> "Richard Reynolds" <richiereynolds@ntlworld.com>
>
[quoted text clipped - 5 lines]
> (  )   Blair
> (  )   Churchill.

I believe that Richard was being metaphoric, referring to the apparently
extremely oppressive nature of the OP's workplace where the OP would be afraid
to speak truth even when it is their job to do so.  I do not believe that
Richard literally thought the OP worked in the actual historic Nazi Germany.
Richard's comment was meant to draw a parallel through metaphor.

And it doesn't look like Tony Blair is going to be able to hold his seat much
longer.  Something about the British public blaming him for involving the UK
in George Bush's Middle East fiasco of oppression and hegemony.

Hmm, who is the President of the United States:

(  ) George W. "Dubya" Bush
(  ) Adolf Hitler
?

To the OP -
Don't be a coward.  If your job is to tell the truth, tell the truth.  If you
aren't willing to do that then you are not being responsible, and in fact
would deserve the contempt some have expressed over the idea of not doing a
code review properly.

Signature

Lew

Harald Kästel-Baumgartner - 11 May 2007 14:06 GMT
> Harald Kästel-Baumgartner wrote:
>> "Richard Reynolds" <richiereynolds@ntlworld.com>
>>
>>> My god! where do you work? Nazi Germany?
>>
>> Oh, you missed a lot the last 60 years.

...
> I believe that Richard was being metaphoric, referring to the apparently
> extremely oppressive nature of the OP's workplace where the OP would be
> afraid to speak truth even when it is their job to do so.  I do not
> believe that Richard literally thought the OP worked in the actual
> historic Nazi Germany. Richard's comment was meant to draw a parallel
> through metaphor.

Hmm...  I agree. I didn't catched the metaphor.

--harald
Richard Reynolds - 11 May 2007 22:06 GMT
>> Harald Kästel-Baumgartner wrote:
>>> "Richard Reynolds" <richiereynolds@ntlworld.com>
[quoted text clipped - 14 lines]
>
> --harald

Thanks Lew, indeed I was, different languages I guess.

Lew said:
> And it doesn't look like Tony Blair is going to be able to hold his seat
> much longer.  Something about the British public blaming him for involving
> the UK in George Bush's Middle East fiasco of oppression and hegemony.

> Hmm, who is the President of the United States:

> (  ) George W. "Dubya" Bush
> (  ) Adolf Hitler
> ?

looks like it's Brown pretty shortly, 14th June I think I heard on the radio
today, and as for the U.S., at least you guys have a rule that'll stop that
muppet serving another term ... if Blair had've gone after term two he'd
have been remembered as a great Prime Minister!
Oliver Wong - 11 May 2007 16:08 GMT
> To the OP -
> Don't be a coward.  If your job is to tell the truth, tell the truth.
> If you aren't willing to do that then you are not being responsible, and
> in fact would deserve the contempt some have expressed over the idea of
> not doing a code review properly.

   I'm not sure it's all that simple. The OP seems to believe that
telling the truth may cost them their job, and maybe their financial
situation is such that they can't afford to be jobless right now. Better
to suffer the contempt of a few people on newsgroup than to be homeless
for a few months, and get a really bad credit rating when you fail to pay
off your credit cards, right?

   I think the optimal strategy for the OP really depends on a multitude
of factors, such as the psychological group dynamics of his coworkers and
bosses; too many factors, in fact, to probably ever properly summarize in
a newsgroup posting. In the end, we can offer the OP information (e.g.
that there exists some work environments where you can perform actual code
reviews without endangering your own employment), but it's up to the OP to
make the final evaluation of what to do.

   - Oliver
a24900@googlemail.com - 10 May 2007 22:35 GMT
> I have found that "code review" or "software testing" is really easy to
> get into trouble with the team members, no matter how polite or careful
> you are. Why? Because:
>
> Nobody likes his code to be found has "error".

Maybe you don't like it. The good programmers say "thank you", and
they mean it. Then they fix the code. Why, because they know it is
better a colleague finds a problem and gives one a chance to fix it,
than the boss having a word with one about the "constant lack of
quality" in the code.

It feels much worse if you are the one whos bug blew the deployment of
the software at the real big and important customer, than getting a
hint from a colleague.

> But it will be very bad in the same team, when
> he just finished his code and tell him that something is not right.  He
> will say "Thank you" to me. But I will never expect good mood between
> him and me.

Well, if a clueless newbie, e.g. one who thinks he is a programmer but
doesn't even know about code reviews, comes up with alledged bugs
every half an hour, and it turns out these are usually no bugs or
irrelevant (outside of specification), or a matter of taste, that can
certainly affect the mood.

If it is a colleague who has the respect of his team, e.g. knows what
he is doing and who doesn't brag about it if he found a bug, then  the
mood will actually get better.

> So, no matter what textbook about program testing says, ("non-biased",
> "thoroughly", ....), practically, I would just pretend I have reviewed
> the code, I have tested it and let the program go.

And when the thing blows up, the boss will come back and ask you how
you could miss that obvious fault in the code review. And it is easy
to get caught. The original programmer has an excuse for not seeing an
obvious bug, he is to involved and immersed into the task. You have no
excuse for not spotting things.

Kid, if you are paid for reviewing some code, do it. And do it right.

And if your own code is reviewed and bugs are found, say "thank you",
and fix it. Don't act up.

> (I will point out one
> or two extremely light errors to the author.)

You are an idiot.

> The author will get what he wants,

You have no clue what he wants.

>I get what I want: no enemy and keep my job.

No, you are risking your job.

Actually, I should probably encourage you to risk your job. Maybe
you'll leave the programming profession for good. I hate to work with
slimy, artificial agreeableness people who have no spine.
Wojtek - 10 May 2007 23:57 GMT
www wrote :
> I have found that "code review" or "software testing" is really easy to get
> into trouble with the team members, no matter how polite or careful you are.

Have you ever worked as a tester?

When you find a bug, you must go to the author of the code and inform
them that they made a mistake. You quickly learn to be really tactful.

This is the same situation.

Words really make a difference. Rather than "You idiot, what are doing
here", say "I think we need to look at this again".

And your team leader can make a big difference by not allowing personal
remarks to be said, from both sides.

If everything is kept at a professional level, it actually goes quite
well. Everyone must remember that they will be in the hot seat next
meeting.

Signature

Wojtek :-)

Arne Vajhøj - 11 May 2007 01:45 GMT
> Thank you all for your replies. Now, I have learned a lot about "code
> review" and software testing.
[quoted text clipped - 20 lines]
> or two extremely light errors to the author.) The author will get what
> he wants, fame or whatever, I get what I want: no enemy and keep my job.

It is a potential problem.

But a good technical leadership will be able to solve the problem.

Key points are:
1)  teach everybody that criticism is a natural way to improve and
    that as professionals they should embrace the idea
2)  keep the review in a good tone

re 1)

If they are true professionals then they will understand. If not then
maybe they should go in another direction careerwise.

re 2)

"You stupid idiot you forgot to test for null in method X !"

and

"Could we improve the code by testing for null in method X so we can
handle sitiation where ... ?"

will probably be perceived differently.

Note that in some environments (typical males below 30 only), then
the tone may be very harsh but then the one making the mistake gives
beer during Friday evening drinking and Monday morning there are
no hard feelings (maybe some hangovers).

Arne
B - 11 May 2007 15:12 GMT
> Thank you all for your replies. Now, I have learned a lot about "code
> review" and software testing.
[quoted text clipped - 20 lines]
> or two extremely light errors to the author.) The author will get what
> he wants, fame or whatever, I get what I want: no enemy and keep my job.

You really don't work in a very good company/team if this is how is works.
Either your place of work really, really sucks, or you have completely
misunderstood something.
tjmadden1128@gmail.com - 11 May 2007 16:30 GMT
<snip>
> Nobody likes his code to be found has "error". It is completely OK for
> the systems to be found behave incorrectly one or two years later,
[quoted text clipped - 5 lines]
> will say "Thank you" to me. But I will never expect good mood between
> him and me.
I would be embarrassed, and try to modify my habits to not do the
error again, but I would not blame the person who found it. I've never
had anyone get mad because I found a problem. Sometimes they might
want me to demonstrate the problem, or explain what was found. The
worst case I've seen is reviewing code for offshore developers who
insisted on keeping the old code in the source and commenting it out.
This led to methods that were hundreds of lines long, most of it code
that was commented out.
I've done tons of code review; as a senior developer on a project, I
reviewed code from new hires to make sure it met the coding standards
for the project, looked for any pitfalls peculiar to the project they
may not know about, and to make sure it met the request. I've done
formal reviews where a group gets together to go over changes to a
framework. I've done pair programming, although I don't find it very
productive. I get bored as the reviewer, and my attention wanders. As
the coder, I feel a little creepy having someone watch over my
shoulder. But that's just me.

> So, no matter what textbook about program testing says, ("non-biased",
> "thoroughly", ....), practically, I would just pretend I have reviewed
> the code, I have tested it and let the program go. (I will point out one
> or two extremely light errors to the author.) The author will get what
> he wants, fame or whatever, I get what I want: no enemy and keep my job.
Which in any organization I have been a part of would get you called
to task and hauled into a manager's or CEO's office. If your
organization does not track who did the review and ask why they did
not find the problem, then there is no point in doing it or even
pretending. In rare cases the problem would get your companies name
splashed across the media. In all cases, this undermines the
confidence of management in your team, makes the rest of the code
suspect, and loses business for the company.

Tim
Chris Smith - 11 May 2007 17:14 GMT
> I would be embarrassed, and try to modify my habits to not do the
> error again, but I would not blame the person who found it.

I find being embarrassed about programming errors to be nearly as
unhealthy a habit as being hostile, actually.  In a healthy development
environment, programmers realize and accept that errors occur;
understand that they are normal, fix them, and move on.  Change habits,
sure if it's reasonable.  It's often not, and adopting techniques to
eradicate all possible programming errors is likely to lead to nothing
at all getting done.  Embarrassment should never be appropriate.

(One qualifier: the kind of embarrassment that leads to having a good
laugh with your coworkers might be an exception.)

Signature

Chris Smith

Daniel Pitts - 11 May 2007 20:33 GMT
> tjmadden1...@gmail.com <tjmadden1...@gmail.com> wrote:
> > I would be embarrassed, and try to modify my habits to not do the
[quoted text clipped - 13 lines]
> --
> Chris Smith

I agree. I actually deployed some code live recently that was way
broken.  It had gone through our QA process, but they managed to miss
a chunk of functionality not working.   I would have been much happier
to have someone tell me that the code was broken, rather than have a
P! bug on my queue.
tjmadden1128@gmail.com - 14 May 2007 15:52 GMT
> tjmadden1...@gmail.com <tjmadden1...@gmail.com> wrote:
> > I would be embarrassed, and try to modify my habits to not do the
[quoted text clipped - 13 lines]
> --
> Chris Smith

You might be right. I have been bombarded over the years with zero
tolerance for software defects and the fact that there is a process to
achieve it by management that I have a hard time with bugs in the code
I wrote. Logically, I know errors occur, but when you are told they
cost a company X thousands of dollars, time spent, and client
confidence, you want to try harder to avoid making them. The endless
parade of TQM methods such as Six Sigma, RUP, XP, and others convinces
you that it is possible. It's scary that I might have bought into all
of that.

Tim
Lew - 14 May 2007 20:34 GMT
> The endless
> parade of TQM methods such as Six Sigma, RUP, XP, and others convinces
> you that it is possible. It's scary that I might have bought into all
> of that.

Perhaps the "parade" convinces you, but it convinces me of the opposite.

There is a little booklet called /Wicked Problems, Righteous Solutions/ that
is worth a read.  It points out that software development is a "wicked"
problem in the formal sense - its solutions are highly sensitive to initial
analysis in generally unpredictable ways.  If the problem were so easily
solvable then one or another of these products would have already captured the
market.

The endless parade of cosmetic products alleged to reverse the appearance of
fine lines caused by aging does little to convince me that a Fountain of Youth
is possible, either.  Generally, endless parades of products that promise the
impossible convince me only that P. T. Barnum was right in his assessment of
the public.

This is not to say that you should give up and just accept bugs.  Au contraire.

Signature

Lew

tjmadden1128@gmail.com - 15 May 2007 14:10 GMT
> tjmadden1...@gmail.com wrote:
> > The endless
[quoted text clipped - 21 lines]
> --
> Lew

No, I think these methods have merit. The company I used to work for
tended to think each one was the silver bullet that would make their
software bug-free, thus they were applied forcefully and without any
regard to whether they were needed for a project. Most people are a
little less accepting of things that are shoved down their throats. I
have yet to find a company doing TDD, though (granted, I've only had
two jobs in the last twenty years.)

Tim
Andy Dingley - 14 May 2007 16:36 GMT
> Nobody likes his code to be found has "error". It is completely OK for
> the systems to be found behave incorrectly one or two years later,
> because it is different branch people (or even different company) to
> debug and maintain the software.

I guess your code is always perfect anyway. After all, you must have
at least 20 years experience to have such an antiquated attitude to
software development. Are you by any chance a MUMPS coder?

Go and find something to read. Mc Connell's "Rapid Application
Development" might do for starters (it's only 10 years out of date, so
it'll lead you into the present gradually). Otherwise something by
Martin Fowler or Kent Beck with "Agile" or "Refactoring" in the title.
Even just bwosing wikipedia for "ego-less coding", "collective code
ownership" or "Getting a first resemblance of a clue, 101"
Mark Rafn - 10 May 2007 21:23 GMT
>According to what I heard, "code review" is somebody reads the thousands
>lines of code written by other person and try to find if there are some
>errors (logic errors, I guess, since the code at least can be compiled
>and run).

Sure, but you should do it when it's hundreds of lines of code, not thousands,
and one of the things you're looking for is enough documentation of what is
intended and how it works that you can follow it.

Think of it as "is this code well-organized, documented, and useful enough
that I'm willing to maintain it when the author is gone?"

>I feel this is crazy!!! Since the reviewer has to "read" the original
>code author's mind and make sure the code does what the author wants and
>no hidden surprises!

Well, if you have to read their mind, your review is "this doesn't pass my
review - you need more design and functional comments so I can tell what
you're trying to do and why."

>How this could be possible?! This would be extremely time consuming

Not compared to having to figure it out or rewrite it later, after the
author has left the company.

>and nobody knows better about the code than the author.

This is one of the primary failures the code review helps prevent.  Writing
code for future maintainence is difficult, but for anything worked on by more
than one or two people as a hobby, it's the single most important aspect of
the work.

>My boss says this is very common practice in software engineer development.

Nearly universal, in any good dev team.  Failure to do code reviews would be
one sign of a sick process.

I've heard of teams that do group code reviews, and have the whole team in a
room with a projector going over every line.  That seems insane to me.

Having another dev look at your code and suggest improvements to style,
patterns, documentation, and functionality is beneficial to you, the other
dev, and to the codebase.
--
Mark Rafn    dagon@dagon.net    <http://www.dagon.net/>
Stefan Ram - 10 May 2007 22:52 GMT
>I've heard of teams that do group code reviews, and have the
>whole team in a room with a projector going over every line.
>That seems insane to me.

 Insane to do if someone's life depends on the software?

     »[This] is one of just four outfits in the world to win
     the coveted Level 5 ranking of the federal governments
     Software Engineering Institute

     Consider these stats : the last three versions of the
     program -- each 420,000 lines long-had just one error
     each. (...)

     Otherwise, the hour-long meeting is sober and revealing, a
     brief window on the culture. For one thing, 12 of the 22
     people in the room are women, many of them senior managers
     or senior technical staff. [This] group, with its
     stability and professionalism, seems particularly
     appealing to women programmers.

     The central group breaks down into two key teams: the
     coders - the people who sit and write code -- and the
     verifiers -- the people who try to find flaws in the code.

     The two outfits report to separate bosses and function
     under opposing marching orders. The development group is
     supposed to deliver completely error-free code, so perfect
     that the testers find no flaws at all. The testing group
     is supposed to pummel away at the code with (...)
     scenarios and simulations that reveal as many flaws as
     possible. (...)

     The developers have even begun their own formal
     inspections of the code in carefully moderated sessions, a
     rigorous proof-reading they hope will confound the
     testers. [The] group now finds 85% of its errors before
     formal testing begins, and 99.9% before the program is
     delivered (...)«

http://www.fastcompany.com/online/06/writestuff_Printer_Friendly.html
chandan - 11 May 2007 20:39 GMT
> >I've heard of teams that do group code reviews, and have the
> >whole team in a room with a projector going over every line.
[quoted text clipped - 37 lines]
>
> http://www.fastcompany.com/online/06/writestuff_Printer_Friendly.html

Code review is not a process to find out the bugs/logical errors/
function malfunctioning behaviour. It is just a process where
experienced programmer/s have a look at your workspace and tries to
point your attention towards some general mistakes which a new comer
could do, to name a few...
1. Giving variable/methods/class/package names which make no sense for
others , like var1,functionOne() et all.
2. Placing constant strings to different class.
3. If you are writting a DAO , then you may put your queries in the
same class.
4. Putting much logic in the same method, which could have been
segregated.
5. Stretching the length of a class to its limit.

So the code review is the process in which best practices are advised
to you so that you start following them, as it makes one's life easier
when re-visited your own code after some decent gap.

And above all writting a logic is not the end of road, it also matters
sometimes how others can easily grasp your code.

Chandan
Joe Attardi - 11 May 2007 21:00 GMT
> Code review is not a process to find out the bugs/logical errors/
> function malfunctioning behaviour. It is just a process where
> experienced programmer/s have a look at your workspace and tries to
> point your attention towards some general mistakes which a new comer
> could do

I have to disagree. Experienced programmers make mistakes just like
anybody else. And it isn't just for mistakes, it certainly is also for
finding potential bugs/logical errors/etc. This is not unique to
programming. It's why professional journal articles are peer reviewed
before they are published. You will always miss some problems in your code.
Stefan Ram - 10 May 2007 22:57 GMT
>Nearly universal, in any good dev team.  Failure to do code
>reviews would be one sign of a sick process.

 Regarding the attitude towards blaming:

     »Importantly, the group avoids blaming people for errors.
     The process assumes blame - and it's the process that is
     analyzed to discover why and how an error got through. At
     the same time, accountability is a team concept: no one
     person is ever solely responsible for writing or
     inspecting code. "You don't get punished for making
     errors," says Marjorie Seiter, a senior member of the
     technical staff. "If I make a mistake, and others reviewed
     my work, then I'm not alone. I'm not being blamed for this."«

http://www.fastcompany.com/online/06/writestuff_Printer_Friendly.html
a24900@googlemail.com - 10 May 2007 22:10 GMT
> My boss just told me a concept I didn't know. (I am middle level Java
> programmer.) -- "code review".

How did you manage to become a programmer without knowing that? A NASA
study from 1987 (yes, the idea is old and established) found that one
finds twice as much faults this way compared to testing. Other, later
sources have found an advantage of 20:1 or 33:1 in time spend on
finding and fixing faults ( which might be exaggerated).

> According to what I heard, "code review" is somebody reads the thousands
> lines of code written by other person

There is a difference between a code-monkey and a real programmer.

The average amount of code a real programmer writes is in the hundreds
of lines per month. That is average, and assumes thorough research of
the problem to solve, thought-out hand-written code, and code
documentation in an non-trivial field of work in a corporate
environment. I am not talking about endless copy-paste junk. It
further assumes tests are counted separately.

> errors (logic errors, I guess, since the code at least can be compiled
> and run).

Or, like, for example, multi threading errors? Potential performance
or scaling problems? Potential access right problems? Potential
deployment problems? Resource conflict problems?

And of course the biggies, too. Like misunderstanding or
misinterpreting of specification. Plus the human component, e,g,
weeding out slackers who didn't report their progress accurately, and
are of course behind schedule. Or fakers who can't code at all but got
the job with a faked CV.

> I feel this is crazy!!!

Programmers who don't want that other programmers look at their code
usually have something to hide. Real programmers typically like to
show their code to demonstrate their competence and get
acknowledgments from their peers.

> Since the reviewer has to "read" the original
> code author's mind

No, the reviewer has to read the specification.

> and make sure the code does what the author wants

No, makes sure the code does what the specification says.

> and no hidden surprises! How this could be possible?! This would be
> extremely time consuming and nobody knows better about the code than the
> author.

If the author is the only one capable of understanding and handling
the code then the code has no long-term value. If the code is
unreadable or incomprehensible for others, it has a major fault, it is
unmaintainable. Code reviews are already valuable if all they could do
was to guard against unmaintainable code.

> My boss says this is very common practice in software engineer development.

Your boss has a clue. A rare event in some corporate environments.
Consider listen to him, there are much worse bosses out there.
Arne Vajhøj - 11 May 2007 01:37 GMT
> My boss just told me a concept I didn't know. (I am middle level Java
> programmer.) -- "code review".
[quoted text clipped - 13 lines]
>
> Is this true? Or my understanding from my boss is wrong?

Yes. It is very common.

What makes it work is that:
- you can see if the code follow company coding standards and
  conventions without understanding what it does (this part is
  so trivial that it can even automated and done by software)
- you can see if the code is well structured without understanding
  what it does (this part is so trivial that it can be automated
  and done by software)
- the reviewers check whether the code does what it is supposed to
  do by comparing the actual code with design documentation and
  comments in the code

Arne
www - 11 May 2007 16:43 GMT
Thank you all for the replies and discussions. I consider that most of
them are healthy. I really appreciate your time.

From the replies, I have learned some key words or new concepts, e.g.
"egoless programming", or related web links. From them, I have learned a
lot issues in software engineering or become aware of their existence.
These issues are hard to discuss openly in my working place and they are
not taught in Computer Science class rooms. Fortunately, through the
newsgroup, I can ask and learn here. In the end, I just want to cite one
of many things I have read from the materials provided by one replier:

<quote>
How do they write the right stuff(software)?

The answer is, it's the process. The group's most important creation is
not the perfect software they write -- it's the process they invented
that writes the perfect software.
</quote>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.