Code review checklist for Java developers

Upasana | October 16, 2020 | | 24 views


Apart from functional requirements, here is the code review checklist while reviewing any Java code:

Clean Code

Code should be clean and follow design patterns wherever applicable

  • High Cohesion and Loose Coupling

  • Design Patterns - DRY and SRP

  • is there a potential for useful abstractions

Concurrency

Thread-safety and concurrency related guidelines

  • Do not create adhoc threads, instead use shared Executors wherever possible.

  • Immutability for better thread-safety.

  • Synchronize access to shared mutable data.

  • Use non-blocking libraries and framework (webflux, kotlin coroutines), where needed.

Reusability

Existing libraries and methods should be reused wherever possible. Do not reinvent the wheels.

Performance
  • Time and Memory complexity of the code.

  • Release resources after use (File Handles, db connections, etc)

  • Avoid dynamic SQL, use prepared statements

Error Handling
  • Proper error handling for negative scenarios, input should be validated before any processing.

  • Use checked exceptions for recoverable conditions and runtime exceptions for programming errors

Readability
  • Classes and methods should be small in terms of number of lines.

  • Explain yourself in the code.

  • Use Guava or Apache commons libraries wherever possible.

  • Did I grasp the concepts in a reasonable amount of time by looking at the code?

Code Convention & Consistency
  • Meaningful naming convention, code should explain itself. Name of the variables, methods and classes should be intention revealing in nature.

  • Standard Code formatting across project

  • Code consistency with the existing culture of writing the code

  • Consistent method signatures (return optional instead of null for Java code)

Regression
  • Side effect on existing code, does this change break backward compatibility? Versioing of endpoint!

Security
  • OWASP standards for the security

  • Do not log any sensitive information, neither put it into the query parameters.

Inter service communication
  • Whether synchronous inter service communication can be avoided?

  • How to handle service invocation failures

  • Can we use non-blocking mechanism for inter service communication?

  • Using Pub/Sub or event driven approach instead of synchronous communication wherever possible

Unit Testing

Proper unit tests that covers the functional requirements.


Top articles in this category:
  1. What do you understand by Java Memory Model?
  2. can we write a java method that swaps two integers
  3. CRC32 checksum calculation Java NIO
  4. What is Double Checked Locking Problem in Multi-Threading?
  5. How will you increment each element of an Integer array, using parallel operation
  6. What is left shift right shift and unsigned rght shift operator in Java
  7. Difference between JDK JRE and JVM

Recommended books for interview preparation:

Find more on this topic:
Buy interview books

Java & Microservices interview refresher for experienced developers.