121-java-object-oriented-design
Skill452 starsChanged 3 months agoApache-2.0View on GitHub
Use when reviewing, improving, or refactoring Java object-oriented design, including applying SOLID, DRY, or YAGNI; improving classes and interfaces; correcting encapsulation, inheritance, or polymorphism; resolving God Class, Feature Envy, or Data Clumps; and improving object creation, methods, or exception contracts. Triggers include review Java OOD, refactor Java OOD, improve Java OOD, fix OOP misuse, and identify Java code smells. Part of Plinth Toolkit
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 8 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Before applying any OOD changes, ensure the project compiles.
- Very specific: line 29
MANDATORY: Run ./mvnw compile or mvn compile before applying any change
- Distinctive: line 30
SAFETY: If compilation fails, stop immediately and do not proceed — compilation failure is a blocking condition
- Very specific: line 31
VERIFY: Run ./mvnw clean verify or mvn clean verify after applying improvements
- Distinctive: line 33
MULTI-CONCERN CHANGES: Read multiple focused references only when the request or diagnosed code problems cross concern boundaries
- Distinctive: line 37
ADJACENT SKILLS: Use skill 122 for dedicated type-design work and skill 126 for dedicated exception-handling work.
- Distinctive: line 38
EDGE CASE: If request scope is ambiguous, stop and ask a clarifying question before applying changes
- Distinctive: line 39
EDGE CASE: If required inputs, files, or tooling are missing, report what is missing and ask whether to proceed with setup guidance
- Very specific: line 56
Run ./mvnw compile or mvn compile and stop immediately if compilation fails.
- Distinctive: line 72
If the request is dedicated type-design work, use skill 122.
- Distinctive: line 89
Read every reference required by a cross-concern refactoring, but do not read unrelated references.
- Very specific: line 109
Run ./mvnw clean verify or mvn clean verify after applying improvements.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Java Object-Oriented Design Guidelines
Review and improve Java code using focused object-oriented design references selected after assessing the request and affected code.
What is covered in this Skill?
- Fundamental design principles (SOLID, DRY, YAGNI)
- Class and interface design: composition over inheritance, immutability, accessibility minimization, accessor methods
- Core OOP concepts: encapsulation, inheritance, polymorphism
- Object creation patterns: static factory methods, Builder, Singleton, dependency injection, avoiding unnecessary objects
- OOD code smells: God Class, Feature Envy, Inappropriate Intimacy, Refused Bequest, Shotgun Surgery, Data Clumps
- Method design: parameter validation, defensive copies, careful signatures, empty collections over nulls, Optional usage
- Exception handling: checked vs. runtime exceptions, standard exceptions, failure-capture messages, no silent ignoring
Scope: Classify the applicable OOD concerns first, then load only the focused references needed for those concerns. Load multiple references when a refactoring crosses concern boundaries.
Constraints
Before applying any OOD changes, ensure the project compiles. If compilation fails, stop immediately — do not proceed until resolved. After applying improvements, run full verification.
- MANDATORY: Run
./mvnw compileormvn compilebefore applying any change - SAFETY: If compilation fails, stop immediately and do not proceed — compilation failure is a blocking condition
- VERIFY: Run
./mvnw clean verifyormvn clean verifyafter applying improvements - PROGRESSIVE DISCLOSURE: Classify the applicable OOD concerns before reading references, then read only the references mapped to those concerns
- MULTI-CONCERN CHANGES: Read multiple focused references only when the request or diagnosed code problems cross concern boundaries
- PRESERVE BEHAVIOR: Apply focused, incremental refactorings without changing observable business behavior
- INCREMENTAL SAFETY: Compile after each significant refactoring and keep changes easy to revert if validation reveals a regression
- DEPENDENCY SAFETY: Confirm refactoring does not break imports, dependencies, class relationships, or established contracts
- ADJACENT SKILLS: Use skill 122 for dedicated type-design work and skill 126 for dedicated exception-handling work; use the overlapping skill 121 references only when those topics are part of a broader OOD review
- EDGE CASE: If request scope is ambiguous, stop and ask a clarifying question before applying changes
- EDGE CASE: If required inputs, files, or tooling are missing, report what is missing and ask whether to proceed with setup guidance
When to use this skill
- Review Java code for object-oriented design
- Refactor Java code for object-oriented design
- Improve Java code for object-oriented design
- Fix OOP concept misuse in Java code
- Identify and resolve code smells in Java code
- Improve object creation patterns in Java code
- Improve method design in Java code
- Improve exception handling in Java code
Workflow
- Compile project before OOD changes
Run ./mvnw compile or mvn compile and stop immediately if compilation fails.
- Assess code and classify OOD concerns
Analyze the request and affected Java code before reading implementation guidance. Classify each relevant problem into one or more concerns:
- Fundamental principles: SOLID, DRY, or YAGNI violations.
- Core OOP concepts: encapsulation, inheritance, or polymorphism misuse.
- Code smells: God Class, Feature Envy, Inappropriate Intimacy, Refused Bequest, Shotgun Surgery, or Data Clumps.
- Object creation: factories, builders, singletons, dependency injection, or unnecessary object creation.
- Classes and interfaces: accessibility, public fields, mutability, composition, or inheritance design.
- Enums and annotations: int constants, ordinals, bit fields, ordinal indexing, or missing
@Override. - Methods: parameter validation, defensive copies, signatures, null collections, or
Optional. - Exceptions: exception contracts that are part of the broader OOD review.
If the request is dedicated type-design work, use skill 122. If it is dedicated exception-handling work, use skill 126.
- Read only applicable OOD references
Map the classified concerns to focused references:
- For SOLID, DRY, or YAGNI, read
references/121-java-object-oriented-design-principles.md. - For encapsulation, inheritance, or polymorphism, read
references/121-java-object-oriented-design-oop-concepts.md. - For object-oriented code smells, read
references/121-java-object-oriented-design-code-smells.md. - For factories, builders, singletons, dependency injection, or unnecessary objects, read
references/121-java-object-oriented-design-object-creation.md. - For class and interface boundaries, accessibility, mutability, composition, or inheritance design, read
references/121-java-object-oriented-design-classes-interfaces.md. - For enums, ordinals, bit fields, enum lookup, or
@Override, readreferences/121-java-object-oriented-design-enums-annotations.md. - For method contracts, validation, defensive copies, signatures, collection returns, or
Optional, readreferences/121-java-object-oriented-design-methods.md. - For exception contracts within a broader OOD review, read
references/121-java-object-oriented-design-exceptions.md.
Read every reference required by a cross-concern refactoring, but do not read unrelated references.
- Apply focused refactorings
Prioritize findings by impact: CRITICAL, MAINTAINABILITY, FLEXIBILITY, or CODE_QUALITY. Apply the smallest suitable refactoring for each diagnosed concern while preserving observable behavior:
- Extract classes or methods to restore focused responsibilities.
- Introduce or refine abstractions for extension, interface segregation, and dependency inversion.
- Correct inheritance hierarchies to preserve substitutability, or replace inheritance with composition.
- Move behavior to eliminate Feature Envy and improve encapsulation.
- Introduce cohesive value or parameter objects for Data Clumps.
- Hide exposed state and reduce unnecessary coupling.
Apply changes incrementally and compile after each significant refactoring.
- Verify with full build
Run ./mvnw clean verify or mvn clean verify after applying improvements.
- Report applied OOD improvements
Report findings by impact and concern, focused references used, refactorings applied, maintainability/flexibility/testability benefits, behavior-preservation evidence, and the final compilation and test result.
Reference
For detailed guidance, examples, and constraints, see:
- references/121-java-object-oriented-design-principles.md
- references/121-java-object-oriented-design-oop-concepts.md
- references/121-java-object-oriented-design-code-smells.md
- references/121-java-object-oriented-design-object-creation.md
- references/121-java-object-oriented-design-classes-interfaces.md
- references/121-java-object-oriented-design-enums-annotations.md
- references/121-java-object-oriented-design-methods.md
- references/121-java-object-oriented-design-exceptions.md
Other versions2 projects use a version of this.
Word for word · 1
- jabrena/plinth★ 448100% same
Edited · 1
- jabrena/cursor-rules-examples★ 264% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository124 other files it gives its agents.
- AGENTS.mdAGENTS.md
- 001-commands-inventorySkill
- 002-agents-inventorySkill
- 003-skills-inventorySkill
- 004-commands-installationSkill
- 005-agents-installationSkill
- 012-agile-epicSkill
- 013-agile-featureSkill
- 014-agile-user-storySkill
- 021-problem-framingSkill
- 022-root-cause-analysisSkill
- 023-assumption-analysisSkill
- 024-context-mappingSkill
- 025-quality-attribute-discoverySkill
- 030-architecture-adr-generalSkill
- 033-architecture-diagramsSkill
- 041-planning-plan-modeSkill
- 042-planning-openspecSkill
- 043-planning-github-issuesSkill
- 044-planning-jiraSkill
- 045-planning-azure-devopsSkill
- 051-design-two-steps-methodsSkill
- 052-design-hamburger-methodSkill
- 053-design-simple-rulesSkill
- 054-design-tddSkill
- 055-design-parallel-changeSkill
- 056-design-avoid-breaking-changesSkill
- 057-design-feature-togglesSkill
- 058-design-bddSkill
- 059-design-atddSkill
- 110-java-maven-best-practicesSkill
- 111-java-maven-dependenciesSkill
- 112-java-maven-pluginsSkill
- 113-java-maven-documentationSkill
- 114-java-maven-searchSkill
- 122-java-type-designSkill
- 123-java-design-patternsSkill
- 124-java-secure-codingSkill
- 125-java-concurrencySkill
- 126-java-exception-handlingSkill
- 128-java-genericsSkill
- 130-java-testing-strategiesSkill
- 131-java-testing-unit-testingSkill
- 132-java-testing-integration-testingSkill
- 133-java-testing-acceptance-testsSkill
- 141-java-refactoring-with-modern-featuresSkill
- 142-java-functional-programmingSkill
- 143-java-functional-exception-handlingSkill
- 144-java-data-oriented-programmingSkill
- 145-java-refactoring-high-performanceSkill
- 151-java-performance-jmeterSkill
- 152-java-performance-gatlingSkill
- 161-java-profiling-detectSkill
- 162-java-profiling-analyzeSkill
- 163-java-profiling-refactorSkill
- 164-java-profiling-verifySkill
- 170-java-documentationSkill
- 181-java-observability-loggingSkill
- 182-java-observability-metrics-micrometerSkill
- 183-java-observability-tracing-opentelemetrySkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

