Remove redundant shelf lookup (double DB hit)
Type: Performance / Refactor
Priority: P2
Summary
findShelfById() and isFull() each load shelf separately.
Impact
Extra round-trip; worse if shelf becomes remote.
Evidence
bookCommandUseCases.java lines 28 and 33.
if (!shelfAccessPort.findShelfById(shelfAssignmentRequest.shelfId()).isPresent()) {
throw new IllegalStateException(
"Shelf not found with id: " + shelfAssignmentRequest.shelfId());
}
if (shelfAccessPort.isFull(shelfAssignmentRequest.shelfId())) {
throw new IllegalStateException(
"Shelf with id " + shelfAssignmentRequest.shelfId() + " is full");
}
Proposed Fix
Consolidate into single validation call or reuse loaded shelf data.
Acceptance Criteria
- Only one shelf query per placement.
Expected
Shelf validation performs one lookup per placement (or single remote call).
Actual
Shelf is loaded twice: once for findShelfById(), again for isFull().
Remove redundant shelf lookup (double DB hit)
Type: Performance / Refactor
Priority: P2
Summary
findShelfById()andisFull()each load shelf separately.Impact
Extra round-trip; worse if shelf becomes remote.
Evidence
bookCommandUseCases.javalines 28 and 33.Proposed Fix
Consolidate into single validation call or reuse loaded shelf data.
Acceptance Criteria
Expected
Shelf validation performs one lookup per placement (or single remote call).
Actual
Shelf is loaded twice: once for findShelfById(), again for isFull().