Skip to content

Skill: spring-review

Purpose

Review Spring MVC code for alignment with the project best practices and conventions.

When to use

  • During code reviews or pull requests for Spring MVC projects
  • When auditing or refactoring existing MVC codebases
  • Before deploying or releasing new features in a Spring MVC application

Instructions

  1. Layering & Architecture
    • Verify clear separation between Controller, Service, and Repository layers.
    • Ensure no business logic is present in controllers.
    • Check for proper use of interfaces and dependency injection.
  2. DTO & Entity Usage
    • Ensure DTOs are used for API input/output (do not expose entities directly).
    • Validate mapping between DTOs and entities is handled in the service layer or with mappers.
  3. Error & Exception Handling
    • Confirm exception handling is implemented via @RestControllerAdvice or @ControllerAdvice.
    • Ensure meaningful error responses and proper HTTP status codes.
  4. Transaction Management
    • Check correct placement of @Transactional (typically on service methods).
    • Avoid transactional logic in controllers.
  5. Testing
    • Ensure tests use appropriate Spring test slices (e.g., @WebMvcTest, @DataJpaTest).
    • Check for adequate test coverage and focus on behavior, not implementation.
  6. Performance & Security
    • Look for N+1 query issues and inefficient data access patterns.
    • Validate input validation and security annotations (e.g., @Valid, @PreAuthorize).
  7. Documentation & Readability
    • Code should be well-documented, with clear method and variable names.
    • Complex logic should have comments or diagrams if needed.

Output format

Provide a checklist or table with findings for each category:

CategoryPass/FailNotes/Suggestions
Layering & Architecture
DTO & Entity Usage
Error Handling
Transaction Management
Testing
Performance & Security
Documentation

Summarize key issues and recommended actions at the end.

Copyright © MSG Systems Romania AI Labs