Java Best Practices
Java coding conventions and common design patterns with code examples for naming, Streams, exceptions, concurrency, and Optional.
- CCM score
- 47 of 100
- skills.sh installs
- 164
- GitHub stars
- 237
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers naming rules for classes, methods, constants, and packages, plus enum singleton, factory, and Builder patterns
- Includes code snippets for Stream filter-map-collect, try/catch/finally with logged rethrow, fixed thread pools, and Optional handling
- Provides examples of switch expressions in factory methods and
orElseThrowfor missing repository lookups - Designed for Java developers who want quick reference snippets on idiomatic style and common patterns
Install
$ npx -y skills add leavesfly/jimi --skill java-best-practices -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Java 最佳实践技能包
编码规范
命名规范
- 类名:PascalCase(UserService)
- 方法/变量:camelCase(getUserById)
- 常量:UPPER_SNAKE_CASE(MAX_SIZE)
- 包名:小写(com.example.service)
常用设计模式
单例模式(枚举实现):
public enum Singleton {
INSTANCE;
public void doSomething() {}
}
工厂模式:
public class UserFactory {
public static User createUser(String type) {
return switch (type) {
case "admin" -> new AdminUser();
case "guest" -> new GuestUser();
default -> new RegularUser();
};
}
}
Builder 模式:
User user = User.builder()
.name("张三")
.age(25)
.build();
Stream API
List<String> names = users.stream()
.filter(u -> u.getAge() > 18)
.map(User::getName)
.collect(Collectors.toList());
异常处理
try {
// 业务逻辑
} catch (SpecificException e) {
log.error("Error: {}", e.getMessage(), e);
throw new BusinessException("操作失败");
} finally {
// 清理资源
}
并发编程
ExecutorService executor = Executors.newFixedThreadPool(10);
executor.submit(() -> {
// 异步任务
});
Optional 使用
Details
- Repository
- github.com/leavesfly/jimi
- Categories
- Java & JVM, Code Review & Quality
- First seen
- Jun 3, 2026
Similar to Java Best Practices
More Java & JVMjava-fundamentalsSkillpluginagentmarketplace/custom-plugin-java638 installsReference guide covering Java 8-21 syntax, OOP, collections, streams, and exception handling with pattern examples.
125-java-concurrencyPluginjabrena/plinth467 starsUse when you need to apply Java concurrency best practices — including thread safety fundamentals, ExecutorService thread pool management, concurrent design pat
java-expertSkillpersonamanagmentlayer/pcl309 installsExpert Java guidance covering Java 21+ features, Spring Boot, and Maven or Gradle builds with enterprise conventions.
java-devSkilldoccker/cc-use-exp466 installsJava 开发规范 covering naming, DTO Lombok rules, batch and N+1 query avoidance, concurrency safety, and Spring Boot conventions.
java-coding-standardsSkillaffaan-m/ecc14.5K installsJava coding standards for Spring Boot and Quarkus services covering naming, immutability, Optional, streams, and CDI.
142-java-functional-programmingSkilljabrena/plinth401 installsJava refactoring guide for immutability, streams, Optionals, and pure functions, gated by compile and verify builds.