AI Skill Report Card
Developing Java Applications
Java Application Development
Quick Start
Java// Spring Boot REST API example @RestController @RequestMapping("/api/users") public class UserController { @Autowired private UserService userService; @GetMapping("/{id}") public ResponseEntity<User> getUser(@PathVariable Long id) { return userService.findById(id) .map(user -> ResponseEntity.ok(user)) .orElse(ResponseEntity.notFound().build()); } @PostMapping public ResponseEntity<User> createUser(@Valid @RequestBody User user) { User saved = userService.save(user); return ResponseEntity.status(HttpStatus.CREATED).body(saved); } }
Recommendation▾
Add concrete input/output examples showing actual problems and complete solutions, not just code snippets
Workflow
-
Project Setup
- Use Maven/Gradle with Spring Boot for new projects
- Configure application.yml for environment-specific properties
- Set up logging with SLF4J and Logback
-
Architecture Design
- Follow layered architecture: Controller → Service → Repository
- Use dependency injection with @Autowired or constructor injection
- Implement proper exception handling with @ControllerAdvice
-
Development Process
- Write unit tests with JUnit 5 and Mockito
- Use Builder pattern for complex objects
- Implement validation with Bean Validation annotations
-
Code Quality
- Follow Java naming conventions
- Use Optional for null safety
- Implement proper equals(), hashCode(), and toString()
Progress Checklist:
- Project structure created with proper package organization
- Database entities defined with JPA annotations
- Service layer with business logic implemented
- REST endpoints with proper HTTP status codes
- Unit tests with >80% coverage
- Exception handling configured
- Logging added for debugging and monitoring
Recommendation▾
Include specific performance optimization techniques and memory management patterns for enterprise applications
Examples
Example 1: Service Layer Input: Need user management service Output:
Java@Service @Transactional public class UserService { private final UserRepository userRepository; public UserService(UserRepository userRepository) { this.userRepository = userRepository; } public Optional<User> findById(Long id) { return userRepository.findById(id); } public User save(User user) { validateUser(user); return userRepository.save(user); } private void validateUser(User user) { if (user.getEmail() == null || !user.getEmail().contains("@")) { throw new IllegalArgumentException("Valid email required"); } } }
Example 2: JPA Entity Input: User entity with relationships Output:
Java@Entity @Table(name = "users") public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(nullable = false, unique = true) private String email; @OneToMany(mappedBy = "user", cascade = CascadeType.ALL) private List<Order> orders = new ArrayList<>(); // Constructor, getters, setters, equals, hashCode }
Recommendation▾
Provide troubleshooting section with common error messages and their solutions
Best Practices
- Use constructor injection over field injection for better testability
- Prefer composition over inheritance for flexibility
- Use enums instead of constants for type safety
- Implement proper logging levels: DEBUG for detailed info, INFO for business events, ERROR for exceptions
- Use try-with-resources for automatic resource management
- Follow SOLID principles especially Single Responsibility and Dependency Inversion
- Use Stream API for functional-style operations on collections
- Implement proper exception hierarchy with custom exceptions extending RuntimeException
Common Pitfalls
- Don't catch and swallow exceptions without proper handling
- Avoid using raw types - always use generics
- Don't use @Autowired on fields in production code - use constructor injection
- Never compare strings with == - use .equals() or Objects.equals()
- Don't ignore compiler warnings - they often indicate real issues
- Avoid creating unnecessary objects in loops - use StringBuilder for string concatenation
- Don't use @Transactional on private methods - it won't work due to proxy limitations
- Never modify collections while iterating - use Iterator.remove() or collect to new collection