Skip to content

Instantly share code, notes, and snippets.

@feststelltaste
Last active July 12, 2016 21:18
Show Gist options
  • Save feststelltaste/e595146b595a630bceaa11e51bb9dfa9 to your computer and use it in GitHub Desktop.
Save feststelltaste/e595146b595a630bceaa11e51bb9dfa9 to your computer and use it in GitHub Desktop.
Exaggerated ReviewCodeExample
public class ReviewCodeExample {
public static String ID = "review.example";
public BigDecimal getFactor() {
return new BigDecimal(0.1);
}
public Collection<String> getCarNames() {
List<Car> cars = getCarsFromDatabase();
List<String> carNames = new ArrayList(cars.size());
for (Car car : cars) {
if (!carNames.contains(car))
carNames.add(car.getName());
}
return carNames;
}
@feststelltaste
Copy link
Author

feststelltaste commented Jul 12, 2016

Exaggerated code review findings for the code example (from @rgra) above:

  1. Line 0: Compliance: Missing license header and copyright information
  2. Line 1: Comment: Missing JavaDoc for class
  3. Line 1: Naming: Use of name "Example" in production code
  4. Line 3: Comment: Missing JavaDoc for public constant
  5. Line 3: Comment: Missing description about function of constant
  6. Line 3: Java: Non-final public static constant
  7. Line 3: Understanding: Reason for ID not clear in this context
  8. Line 5: Comment: Missing JavaDoc for public method
  9. Line 5: Naming: Conflict with Java Beans naming conventions, because "getFactor" doesn't return the value for an attribute "factor"
  10. Line 5: Understanding: Sense of "getFactor" in the context of class "ReviewCodeExample" unclear
  11. Line 6: Java: Usage of float for BigDecimal imprecise
  12. Line 6: Java: Creation of an unnecessary object for a constant value
  13. Line 9: Comment: Missing JavaDoc for public method
  14. Line 9: Understanding: Method name "getCarNames" unclear. What does "name" mean? Manufacturer? Model name?
  15. Line 10: Java: Missing null check of return value
  16. Line 11: Java: Used Type "List" unnecessarily to specific, return type is "Collection"
  17. Line 11: Java: Usage of ArrayList with raw type
  18. Line 11: Java: Wrong data structure for storing unique elements
  19. Line 11: Understanding: Name "carNames" unclear. What does "name" mean? Manufacturer? Model name?
  20. Line 13: Java: Comparison of wrong types

This is the result of a code review if senseless code review instructions exist in your company.

Please maintain common sense in software development.

Many thanks to @rgra for her great talk about code reviews at Java Forum Stuttgart 2016!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment