Identify and apply data-oriented programming best practices in Java to improve code clarity, maintainability, and predictability by strictly separating data structures from behavior and ensuring all data transformations are explicit, pure, and traceable.
Core areas: Records for immutable data carriers over mutable POJOs, data-behavior separation with pure static utility classes holding operations, pure functions for data transformation that depend only on inputs and produce no side effects, flat denormalized data structures with ID-based references over deep nesting, generic Map representations for dynamic schemas converted to specific types when needed, Optional...
Prerequisites: Run ./mvnw compile before applying any changes. If compilation fails, stop immediately — do not proceed until the project compiles successfully.
當您需要在 Java 中應用面向數據的程式設計最佳實踐時使用 - 包括使用記錄將程式碼(行為)與數據結構分離,使用純轉換函數設計不可變數據,使用基於 ID 的引用保持數據平坦和非規範化,從在需要時轉換為特定類型的通用數據結構開始,透過純驗證函數確保數據平坦和非規範化,從需要時轉換為特定類型的通用數據結構開始,透過純驗證函數確保完整的通用數據存取層。 java 技能專案的一部分 來源:jabrena/cursor-rules-java。