144-java-data-oriented-programming
适合想把数据与行为分离、推行不可变数据的 Java 团队。
提供 Java 中的数据导向编程最佳实践与模式建议。
给 Java 项目提供“数据导向编程”的落地建议:把数据结构和行为分离(推荐用 records)、尽量用不可变对象和纯函数做转换、保持数据扁平并用 ID 关联、先用通用结构再按需转换为具体类型,并用纯校验函数保证数据完整性。适合在重构、优化性能或梳理数据模型时使用,能让代码更易测试、易推理、利于并发。特点是强调纯函数与不可变数据的组合,便于构建通用的数据访问层。
▸ 展开 SKILL.md 英文原文
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
帮我安装这个 skill:https://raw.githubusercontent.com/jabrena/plinth/main/skills/144-java-data-oriented-programming/SKILL.mdcurl -fsSL "https://raw.githubusercontent.com/jabrena/plinth/main/skills/144-java-data-oriented-programming/SKILL.md"# Java Data-Oriented Programming Best Practices Apply data-oriented programming in Java: separate data from behavior with records, use immutable data structures, pure functions for transformations, flat denormalized structures with ID references, generic-to-specific type conversion when needed, pure validation functions, and flexible generic data access layers. All transformations should be explicit, traceable, and composed of clear pure functional steps. **What is covered in this Skill?** - Separation of concerns: data structures (records, POJOs) vs behavior (utility classes, services) - Immutability: records, final fields, transformations produce new instances - Pure data transformation