java-best-practices

Codify Java best practices for code reviews and architectural decisions.

1|Updated Dec 24, 2025
One-click install
npx skills add https://github.com/clostaunau/holiday-card --skill java-best-practices
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: java-best-practices
Source: https://github.com/clostaunau/holiday-card/tree/main/.claude/skills/java-best-practices
Command: npx skills add https://github.com/clostaunau/holiday-card --skill java-best-practices

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill consolidates Java development best practices—SOLID, DRY, Clean Code, modern Java features (Optional, immutability, streams, lambdas), exception handling, collections, concurrency, testing with JUnit 5 and Mockito, code organization, performance optimization, and common anti-patterns—providing a reliable reference for code reviews and architecture guidance.

Core Features & Use Cases

  • Comprehensive guidance: SOLID, Clean Code, DRY, and Java-specific patterns.
  • Testability & quality: Best practices for testing with JUnit 5 and Mockito.
  • Architecture & Performance: Code organization, concurrency, and performance tips.
  • Use Case: During Java project reviews or when writing new Spring-based services, apply these standards to ensure maintainable, scalable code.

Quick Start

Start by reviewing the SOLID and DRY sections, then consult the testing and Spring sections when implementing a new feature in a Spring application.

Frequently Asked Questions about java-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I apply SOLID principles to improve Java code reviews?

SOLID principles guide Java architecture by enforcing single responsibility, open/closed design, and dependency inversion. Apply them during code reviews to identify tight coupling, reduce maintenance burden, and ensure scalable service design across Spring and enterprise projects.

What are the best practices for testing Java applications with JUnit 5 and Mockito?

JUnit 5 and Mockito enable isolated unit testing by separating concerns with annotations and mock objects. Write testable Java code by injecting dependencies, mocking external services, and organizing tests around behavior rather than implementation details.

How do I structure exception handling in Java to follow best practices?

Java exception handling best practices include catching specific exceptions, avoiding empty catch blocks, using checked exceptions sparingly, and propagating or wrapping exceptions meaningfully. This improves debuggability, maintainability, and error recovery in production systems.

What Java features improve code quality: Optional, streams, and lambdas?

Optional eliminates null pointer exceptions, streams enable functional data processing, and lambdas reduce boilerplate. These modern Java features enhance readability, reduce bugs, and make concurrent code safer when applied systematically in new services.

When should I refactor Java code to follow DRY and Clean Code principles?

DRY and Clean Code principles prevent duplication and improve clarity. Refactor during reviews when methods exceed single responsibility, naming obscures intent, or logic repeats across classes—especially in Spring components and shared utilities.

Can I use these Java best practices with Spring Framework applications?

Yes. These best practices directly apply to Spring development: use dependency injection for loose coupling, organize tests with Spring Test and Mockito, apply SOLID to service layer design, and leverage Spring's built-in patterns for exception handling and concurrency.