122-java-type-design

Solid

Use when you need to review, improve, or refactor Java code for type design quality — including establishing clear type hierarchies, applying consistent naming conventions, eliminating primitive obsession with domain-specific value objects, leveraging generic type parameters, creating type-safe wrappers, designing fluent interfaces, ensuring precision-appropriate numeric types (BigDecimal for financial calculations), and improving type contrast through interfaces and method signature alignment. This should trigger for requests such as Review Java code for type design; Improve type design in Java code; Fix primitive obsession in Java code; Create value objects in Java code. Part of cursor-rules-java project

AI & Automation 393 stars 78 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 92/100

Stars 20%
86
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Type Design Thinking in Java Review and improve Java code using comprehensive type design principles that apply typography concepts to code structure and organization for maximum clarity and maintainability. **What is covered in this Skill?** - Clear type hierarchies: nested static classes, logical structure - Consistent naming conventions: domain-driven patterns, uniform interface/implementation naming - Strategic whitespace for readability - Type-safe wrappers: value objects replacing primitive obsession (EmailAddress, Money) - Generic type parameters: flexible reusable types, bounded parameters - Domain-specific fluent interfaces: builder pattern, method chaining - Type weights: conceptual importance — core domain vs supporting vs utility - Type contrast through interfaces: contract vs implementation separation - Aligned method signatures: consistent parameter and return types across related classes - Self-documenting code: clear descriptive names - BigDecimal for precision-sensitive calculations (financial/monetary operations) - Strategic type selection: Optional, Set vs List, interfaces over concrete types **Scope:** The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples. ## Constraints Before applying any type design changes, ensure the project compiles. If compilation fails, stop immediately — do not proceed until resolved. After applying improvements, run full verification. - **MA...

Details

Author
jabrena
Repository
jabrena/cursor-rules-java
Created
1 years ago
Last Updated
today
Language
Java
License
Apache-2.0

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Solid

121-java-object-oriented-design

Use when you need to review, improve, or refactor Java code for object-oriented design quality — including applying SOLID, DRY, and YAGNI principles, improving class and interface design, fixing OOP concept misuse (encapsulation, inheritance, polymorphism), identifying and resolving code smells (God Class, Feature Envy, Data Clumps), or improving object creation patterns, method design, and exception handling. This should trigger for requests such as 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. Part of cursor-rules-java project

393 Updated today
jabrena
AI & Automation Solid

128-java-generics

Use when you need to review, improve, or refactor Java code for generics quality — including avoiding raw types, applying the PECS (Producer Extends Consumer Super) principle for wildcards, using bounded type parameters, designing effective generic methods, leveraging the diamond operator, understanding type erasure implications, handling generic inheritance correctly, preventing heap pollution with @SafeVarargs, and integrating generics with modern Java features like Records, sealed types, and pattern matching. This should trigger for requests such as Improve the code with Generics; Apply Generics; Refactor the code with Generics. Part of cursor-rules-java project

393 Updated today
jabrena
Code & Development Solid

141-java-refactoring-with-modern-features

Use when you need to refactor Java code to adopt modern Java features (Java 8+) — including migrating anonymous classes to lambdas, replacing Iterator loops with Stream API, adopting Optional for null safety, switching from legacy Date/Calendar to java.time, using collection factory methods, applying text blocks, var inference, or leveraging Java 25 features like flexible constructor bodies and module import declarations. This should trigger for requests such as Review Java code for modern Java development; Apply best practices for modern Java development in Java code. Part of cursor-rules-java project

393 Updated today
jabrena
Data & Documents Solid

144-java-data-oriented-programming

Use when you need to apply data-oriented programming best practices in Java — including separating code (behavior) from data structures using records, designing immutable data with pure transformation functions, keeping data flat and denormalized with ID-based references, starting with generic data structures converting to specific types when needed, ensuring data integrity through pure validation functions, and creating flexible generic data access layers. This should trigger for requests such as Improve the code with Data-Oriented Programming; Apply Data-Oriented Programming; Refactor the code with Data-Oriented Programming; Apply Data-Oriented Programming; Refactor the code with Data-Oriented Programming. Part of cursor-rules-java project

393 Updated today
jabrena
Code & Development Solid

145-java-refactoring-high-performance

Use when you need to refactor Java code for high performance — including memory/allocation reduction, CPU hot-path optimization, and syntax/API/control-flow improvements. This should trigger for requests such as Review Java code for high performance; Optimize Java hot path; Reduce Java allocations; Improve Java latency/throughput. Part of cursor-rules-java project

393 Updated today
jabrena