views:

1237

answers:

7

I saw some questions similar but none answer this question. For performing java code reviews what do you often look at. Do you recommend books, articles, tools which impressed you most on it.

+7  A: 

First of all, get some of the literature for Fagan code reviews: there are lots of things in code review that can make them more effective but that aren't language dependent.

After that, I'd look for the following:

  • Class and method size: Big classes and long methods tend to be more brittle.
  • Can you tell what the "secret" of a class is, that is, can you tell how it encapsulates a potential change?
  • In general, look for aggregation over implementing interfaces, and interfaces over inheritance.
  • Especially if you're doing TDD or disciplined unit testing, look for interfaces for most major classes; this makes it easier to build mock objects and to change implementations later.
  • Javadocs meet standards.
  • Avoid complicated compound statements.
  • "Fluent" method names, that is, you want to be able to read the methods as sentences. "if object is initialized" should read if(obj.isInitialized())".
  • Comments reflect what the code does.
  • Code does what's expected.
Charlie Martin
+1  A: 

I think you need a bit more information in your question. In addition, I would add a couple more tags besides Java. Overall, the more detail you provide, the better answers you receive :)

Here are some links to help in answer your questions:

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

Here are a couple of articles that might provide some help: - http://www.developer.com/java/other/article.php/3579756 - http://today.java.net/pub/a/today/2006/08/17/code-reviews.html - Basically, I would Google around and asking on StackOverflow helps

Possible Tools: - http://stackoverflow.com/questions/131153/open-source-code-review-tools-mondrian

daub815
+6  A: 

Here is a not so comprehensive list:

  • Adherence to standards and guidelines (This means you should have coding standards set for your project)
  • Documenatation. All good code must be documented cleanly.
  • repetitive code (candidate for refactoring)
  • meaningful variable names
  • variable and method scopes (private vs public)
  • Use of good design patterns (if possible)
  • Good test cases associated with the code. Preferably automated test cases.(it is not easy to automate all test cases, though it is desirable. If such is the case, it should document how to test the given functionality)

In addition since you spoke about Java, there are many tools available allow you to analyze the code and check for style and code cleanliness and even potential issues.

All of these can be configured with an automated build/continuous integration process and check for issues even before you go through a manual code review. I used PMD and Checkstyle at my last project and I was pleasantly surprised that how many issues were we able to discover and fix even before we sat down for a code review.

Here is an article that I always share with my team for code reviews. This just outlines the general guidelines surrounding code reviews. http://www.developer.com/java/other/article.php/3579756

One thing to note though, is One on one code reviews are not very effective. I personally like to use code reviews as a learning mechanism for other team members to even understand what each person on the team is working on. It should always be a team exercise. It allows junior members some exposure to some good practices.

Deep Kapadia
+1 for good points, summarized well, and excellent links
Ken Paul
+2  A: 

In addition to what was said, I can really recommend Jupiter, the Eclipse code review tool. Works well and they fix any bugs pretty quickly.

Epaga
+1  A: 

not just for java, but there is a web based tool called Crucible for reviewing (code, but can be applicable for other things code oriented, and not just for java).


*disclosure: I work for Atlassian.

Chii
I don't work for Atlassian, but we use Crucible as a plug-in to JIRA, and I can fully recommend Crucible.
Nicolai
+1  A: 

Code Collaborator is another peer code review tool, and one mentioned in other questions about code review.

In fact, Code Collaborator was deemed the "correct answer" and has most-votes in the question "Best tools for code reviews."

(Yes I work for Smart Bear, maker of Code Collaborator.)

Jason Cohen
A: 

I've used both Jupiter and Crucible and I would recommend Crucible if your shop has requirements and conditions such as:

  • Have many different code lines that you want to review quickly
  • Want to have a lot of small reviews to verify changes
  • Have developers working remotely
  • Have developers using different IDEs
  • Your team uses Confluence and Jira. Crucible integrates nicely with the two tools
  • You have the budget to spend money on a code review tool

Jupiter is nice for small, disciplined teams using Eclipse. The mailing list is responsive and the best part is Jupiter is free.

austen