Skip to content

Commit 10600ee

Browse files
committed
Minor chage
1 parent aa66066 commit 10600ee

7 files changed

Lines changed: 86 additions & 120 deletions

File tree

.cursor/rules/143-java-data-oriented-programming.mdc

Lines changed: 59 additions & 106 deletions
Large diffs are not rendered by default.

spml/actual_143_output.txt

Whitespace-only changes.

spml/actual_output.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

spml/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@
240240
<include>131-java-unit-testing.mdc</include>
241241
<include>125-java-concurrency.mdc</include>
242242
<include>126-java-logging.mdc</include>
243+
<include>143-java-data-oriented-programming.mdc</include>
243244
</includes>
244245
</resource>
245246
</resources>

spml/src/main/resources/143-java-data-oriented-programming.xml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<metadata>
77
<!-- Markdown Front Matter for Cursor Rules -->
88
<cursor-ai>
9-
<description>Java Data-Oriented Programming</description>
10-
<globs>*.java</globs>
9+
<description></description>
10+
<globs></globs>
1111
<always-apply>false</always-apply>
1212
</cursor-ai>
1313
<tags>
@@ -24,9 +24,19 @@
2424

2525
<role>You are a Senior software engineer with extensive experience in Java software development</role>
2626

27-
<goal>
27+
<goal><![CDATA[
2828
Apply data-oriented programming principles to Java code, emphasizing immutable data structures, pure functions, and clear separation between data and behavior.
29-
</goal>
29+
30+
### Implementing These Principles
31+
32+
These guidelines are built upon the following core principles:
33+
34+
1. **Separation of Concerns (Data vs. Code)**: Strictly decouple data structures (which should be simple carriers like records or POJOs) from the code (behavior) that operates on them. Behavior should reside in separate utility classes or services.
35+
2. **Immutability**: Design data structures to be immutable. Use records or final fields, and ensure that any transformations on data produce new instances rather than modifying existing ones.
36+
3. **Pure Data Transformations**: Manipulate data using pure functions that depend only on their inputs and produce no side effects. This makes transformations predictable, testable, and easier to reason about.
37+
4. **Simplicity and Flexibility of Data Structures**: Prefer flat, denormalized data structures where appropriate, using IDs for references rather than deep nesting. Start with generic representations (like `Map<String, Object>`) if the schema is dynamic, converting to specific types only when necessary for processing.
38+
5. **Explicit and Traceable Operations**: Ensure all data validation and transformation steps are explicit, composed of clear functional steps, and easily traceable. Avoid hidden or implicit logic within data objects.
39+
]]></goal>
3040

3141
<examples>
3242
<toc auto-generate="true" />

spml/src/test/java/info/jab/xml/CursorRuleGeneratorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void should_produceConsistentStructure_when_processingDifferentXmlTypes() throws
328328
saveGeneratedContentToTarget(unitTestingResult, "131-java-unit-testing.mdc");
329329
saveGeneratedContentToTarget(refactoringWithModernFeaturesResult, "unified-refactoring-with-modern-features.mdc");
330330
saveGeneratedContentToTarget(functionalProgrammingResult, "142-java-functional-programming.mdc");
331-
//saveGeneratedContentToTarget(dataOrientedProgrammingResult, "unified-data-oriented-programming.mdc");
331+
saveGeneratedContentToTarget(dataOrientedProgrammingResult, "143-java-data-oriented-programming.mdc");
332332
}
333333

334334
/**

spml/src/test/resources/143-java-data-oriented-programming.mdc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ description:
33
globs:
44
alwaysApply: false
55
---
6-
---
7-
description: Java Data-Oriented Programming
8-
globs: *.java
9-
alwaysApply: false
10-
---
116
# Java rules to apply data oriented programming style
127

138
## Role
@@ -18,6 +13,16 @@ You are a Senior software engineer with extensive experience in Java software de
1813

1914
Apply data-oriented programming principles to Java code, emphasizing immutable data structures, pure functions, and clear separation between data and behavior.
2015

16+
### Implementing These Principles
17+
18+
These guidelines are built upon the following core principles:
19+
20+
1. **Separation of Concerns (Data vs. Code)**: Strictly decouple data structures (which should be simple carriers like records or POJOs) from the code (behavior) that operates on them. Behavior should reside in separate utility classes or services.
21+
2. **Immutability**: Design data structures to be immutable. Use records or final fields, and ensure that any transformations on data produce new instances rather than modifying existing ones.
22+
3. **Pure Data Transformations**: Manipulate data using pure functions that depend only on their inputs and produce no side effects. This makes transformations predictable, testable, and easier to reason about.
23+
4. **Simplicity and Flexibility of Data Structures**: Prefer flat, denormalized data structures where appropriate, using IDs for references rather than deep nesting. Start with generic representations (like `Map<String, Object>`) if the schema is dynamic, converting to specific types only when necessary for processing.
24+
5. **Explicit and Traceable Operations**: Ensure all data validation and transformation steps are explicit, composed of clear functional steps, and easily traceable. Avoid hidden or implicit logic within data objects.
25+
2126
## Examples
2227

2328
### Table of contents
@@ -869,4 +874,4 @@ class HiddenTransformationExample {
869874
// If multiple such methods are called, the state becomes hard to reason about.
870875
}
871876
}
872-
```
877+
```

0 commit comments

Comments
 (0)