
Java Best Practices
A solid reference card for modern Java patterns and idioms. You get naming conventions,Enum-based singletons, factory and builder patterns with actual snippets, plus practical examples for Streams, Optional, and ExecutorService. The code samples use current Java syntax like switch expressions, which is good to see. It's basically the cheat sheet you'd want open when doing code review or onboarding someone to a Java codebase. The pattern examples are brief but real, not pseudocode. Worth having around if you're enforcing standards across a team or just want quick reminders of idiomatic ways to handle common scenarios without Googling.
- skills.sh installs
- 164
- GitHub stars
- 238
- last updated
- Aug 21, 2026
Install
$ npx -y skills add leavesfly/jimi --skill java-best-practices --agent claude-codeInstalls into .claude/skills of the current project.
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 使用
Sponsors
Promote your product hereReach 125k+ visitors monthlyPromote your product hereReach 125k+ visitors monthly
Agent CaffeineSponsoredClose your lid, come back to finished work
SnugSponsoredThe clipboard manager for the AI eraPromote your product hereReach 125k+ visitors monthly
WaxSponsoredBlock anything with supervision, without erasing your iPhonePromote your product hereReach 125k+ visitors monthly
knobsSponsoredSee your site on any phone, any day, in any language
Details
- Repository
- github.com/leavesfly/jimi
- Category
- Java & JVM
- First seen
- Jun 3, 2026
Recommended
More Java & JVM1
to-spring-or-not-to-springraphaelsalaja/userinterface-wikiAudit animation code for correct timing function selection. Use when reviewing motion implementations, debugging animations that feel wrong, or choosing between152skills.sh installs
5
141-java-refactoring-with-modern-featuresjabrena/cursor-rules-java141 java refactoring with modern features135skills.sh installs
6
131-java-testing-unit-testingjabrena/cursor-rules-java131 java testing unit testing134skills.sh installs