Skip to content

Add Spring Boot Examples to Lab 2 (Requirements to Code) #25

@shawnewallace

Description

@shawnewallace

Lab 2 Java/Spring Boot Version Complete

Created a separate Java version of Lab 2 instead of bilingual approach for better readability and focused learning experience.

Changes Summary

New File: docs/labs/lab-02-requirements-to-code-java.md

  • Size: 1,074 lines (complete Java/Spring Boot adaptation)
  • Commit: 274b7bc

Updated Files:

  • lab-02-requirements-to-code.md - Added cross-reference to Java version
  • docs/labs/README.md - Updated to list both versions

Java/Spring Boot Content

Domain Layer

  • Priority enum with fromString() and fromValue() methods
  • Task entity with JPA annotations (@Entity, @Table, @Column)
  • Factory method pattern: Task.create()
  • LocalDateTime for temporal fields
  • Proper encapsulation with protected default constructor for JPA

Application Layer

  • TaskService interface and TaskServiceImpl
  • @Service, @Transactional, @Slf4j annotations
  • Constructor injection with Lombok's @RequiredArgsConstructor
  • CreateTaskRequest DTO as Java record
  • Structured logging with SLF4J

API Layer

  • TaskController with @RestController and @RequestMapping
  • POST /api/tasks endpoint
  • TaskResponse DTO with @JsonFormat for dates
  • @ExceptionHandler for IllegalArgumentException → 400 Bad Request
  • Location header in 201 Created response

Testing

  • JUnit 5 tests for Task entity
  • Mockito for TaskServiceImpl unit tests
  • @SpringBootTest integration tests with TestRestTemplate
  • Test commands: mvn test, mvn clean test

Developer Experience

  • tasks.http file for REST Client extension
  • curl examples for manual testing
  • Build and run: mvn spring-boot:run

Design Decision: Separate Files

Chose separate files over bilingual approach because:

Better UX: Participants see only relevant content for their stack
Manageable Size: 871 (.NET) and 1,074 (Java) lines vs 1,500+ bilingual
Easier Maintenance: Clear separation of concerns
Cross-References: Links between versions for comparison
Consistency: Lab 1 uses bilingual for foundational concepts, Labs 2+ use separate files for implementation depth

Epic #16 Progress

With this completion: 5 of 15 issues complete (33%)

Next Steps

Continue with:

Lab 2 ready for Workshop 2.0 with both .NET and Java/Spring Boot support! 🎉

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions