197
GitHub Stars
2
Bundled Files
2 months ago
Catalog Refreshed
4 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 veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill leavesfly/jimi --skill java-best-practices- check-java-env.sh837 B
- SKILL.md1.7 KB
Overview
This skill collects practical Java coding conventions, common design patterns, and concise examples for robust application development. It focuses on naming, exception handling, concurrency, Stream API, Optional usage, and patterns like Singleton, Factory, and Builder. Use it to standardize code style and apply proven patterns across projects.
How this skill works
The skill inspects common Java development areas and presents clear, actionable snippets and rules you can apply immediately. It highlights naming conventions, pattern choices, Stream and Optional idioms, exception handling structure, and basic concurrency setups. Each item is framed to reduce bugs, improve readability, and encourage maintainable designs.
When to use it
- Onboard new Java developers to a unified style guide
- Design or refactor modules to apply appropriate design patterns
- Implement safe exception handling and error translation
- Introduce functional-style processing with Stream API
- Add concurrency or asynchronous tasks to backend services
Best practices
- Use PascalCase for class names, camelCase for methods and variables, and UPPER_SNAKE_CASE for constants
- Prefer enum-based Singleton for thread-safe single-instance needs
- Encapsulate complex object creation with Factory or Builder patterns to simplify clients
- Use Stream API for readable collection processing and avoid mutable external state in lambdas
- Catch specific exceptions, log with context, and rethrow domain-specific exceptions; always clean up resources
- Use Optional to represent absent values and orElseThrow to convert missing data to explicit errors
Example use cases
- Create a single, thread-safe service instance using enum Singleton for configuration access
- Provide a UserFactory that returns different user implementations based on type input
- Build complex DTOs or entities with a Builder to keep constructors manageable
- Process collections of users with Stream filter-map-collect to produce lists of names or summaries
- Run background tasks with a fixed thread pool ExecutorService and submit Runnables or Callables
FAQ
Use Builder when an object has many optional fields or when constructor parameter lists become hard to read. Use constructors for simple, mandatory fields for clarity.
Is enum Singleton always best?
Enum Singleton is simple and serialization-safe for single-instance needs. For lazy initialization or dependency-injected singletons, prefer framework-managed singletons or other patterns.