Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build production-ready Spring Boot 3.x applications with REST APIs, Security, Data JPA, and Actuator
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/PATTERNS.md
1# Java Spring Boot Patterns23## Design Patterns45### Pattern 1: Input Validation67Always validate input before processing:89```python10def validate_input(data):11if data is None:12raise ValueError("Data cannot be None")13if not isinstance(data, dict):14raise TypeError("Data must be a dictionary")15return True16```1718### Pattern 2: Error Handling1920Use consistent error handling:2122```python23try:24result = risky_operation()25except SpecificError as e:26logger.error(f"Operation failed: {e}")27handle_error(e)28except Exception as e:29logger.exception("Unexpected error")30raise31```3233### Pattern 3: Configuration Loading3435Load and validate configuration:3637```python38import yaml3940def load_config(config_path):41with open(config_path) as f:42config = yaml.safe_load(f)43validate_config(config)44return config45```4647## Anti-Patterns to Avoid4849### ❌ Don't: Swallow Exceptions5051```python52# BAD53try:54do_something()55except:56pass57```5859### ✅ Do: Handle Explicitly6061```python62# GOOD63try:64do_something()65except SpecificError as e:66logger.warning(f"Expected error: {e}")67return default_value68```6970## Category-Specific Patterns: General7172### Recommended Approach73741. Start with the simplest implementation752. Add complexity only when needed763. Test each addition774. Document decisions7879### Common Integration Points8081- Configuration: `assets/config.yaml`82- Validation: `scripts/validate.py`83- Documentation: `references/GUIDE.md`8485---8687*Pattern library for java-spring-boot skill*88