- Home
- Skills
- Pedrosantiagodev
- Buildup
- Coding Guidelines
coding-guidelines_skill
- Java
0
GitHub Stars
1
Bundled Files
3 weeks ago
Catalog Refreshed
2 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstart where the catalogue uses aiagentskills.
npx veilstart add skill pedrosantiagodev/buildup --skill coding-guidelines- SKILL.md4.3 KB
Overview
This skill provides a concise, opinionated set of coding standards for Java and Spring Boot projects, focusing on robustness, immutability, dependency injection, and maintainability. Use it when writing new features, refactoring existing code, or designing project structure to ensure consistent, safe, and testable code across teams.
How this skill works
The guidelines cover core Java practices (immutability, composition, resource management, generics, lambdas, and concurrency) and Spring-specific patterns (constructor injection, configuration properties, starters, and testing strategies). It explains what to prefer, what to avoid, and concrete techniques to apply during implementation and reviews. Follow the rules to reduce bugs, improve readability, and make modules easier to test and evolve.
When to use it
- Starting a new Java or Spring Boot microservice or module
- Refactoring mutable or tightly-coupled code to improve safety
- Designing domain models and API layers for long-term maintenance
- Writing unit, integration, or slice tests for Spring components
- Onboarding developers to a consistent coding style and architecture
Best practices
- Prefer immutable classes: final class, private final fields, no setters, defensive copies
- Favor composition over inheritance and code to interfaces, not implementations
- Use constructor injection for Spring beans so dependencies can be final and testable
- Prefer try-with-resources for AutoCloseable and avoid finalizers
- Use parameterized generics and bounded wildcards (PECS) to improve API flexibility
- Keep synchronized blocks minimal and use the Executor framework for concurrency
Example use cases
- Designing a service layer: use interfaces, constructor injection, and unit-testable components
- Refactoring an entity: convert mutable DTOs to immutable value objects with defensive copies
- Implementing REST endpoints: @RestController, specific @GetMapping/@PostMapping, and clear validation
- Configuring properties: map settings into a @ConfigurationProperties POJO for type safety
- Integration testing: use Testcontainers with @SpringBootTest or focused test slices
FAQ
Use Optional for return types that may be absent to make nullability explicit; avoid Optional for collections or fields.
Constructor vs field injection?
Prefer constructor injection: it makes dependencies explicit, enables final fields, and simplifies testing.