This plan defines a Java implementation of Deep Coding based on three core layers:
Structural Specification Layer
Machine-readable definitions (OpenAPI, JSON Schema, custom annotations) that serve as the single source of truth.
Skeleton Layer
Immutable interfaces, abstract classes, and module declarations generated from specifications. Human modification is prohibited.
Tissue Layer
Concrete implementations (controllers, services, repositories). Fully generated where possible; partially generated or manually written where domain complexity requires.
src/main/resources/openapi/.@StateTransition(from = "DRAFT", to = "PUBLISHED") generates compile-time validation.module-info.java to declare exports, dependencies, and service bindings.module-info.java as a generated artifact derived from the structural specification.| Generator | Input | Output | Plugin |
|---|---|---|---|
| OpenAPI Generator | OpenAPI YAML | API interfaces, DTOs | openapi-generator-maven-plugin |
| jsonschema2pojo | JSON Schema | POJOs | jsonschema2pojo-maven-plugin |
| Custom annotation processor | Java annotations | Validators, monitors | maven-compiler-plugin (built-in) |
target/generated-sources/ and exclude from version control.| Pattern | Java Construct | Role |
|---|---|---|
| Template Method | abstract class with final template method |
Immutable algorithm structure |
| Interface Contract | Generated API interfaces | Invariant operation signatures |
| Module Boundary | module-info.java |
Physical encapsulation |
Generated Tissue
DTOs, enums, validators, and state monitors are fully generated and never manually edited.
Semi-Generated Tissue
Controllers implement generated interfaces. Implementation can be AI-generated but must be verified against the specification.
Manual Tissue
Service classes contain domain logic. They must be written to depend only on skeleton interfaces and generated DTOs.
Use ArchUnit to enforce:
| Gate | Tool | Enforced Property |
|---|---|---|
| Module integrity | JPMS | No cyclic dependencies; exported packages only |
| Null safety | Checker Framework (NullnessChecker) |
@NonNull/@Nullable contracts |
| Type state | Checker Framework (OptionalChecker) |
Correct Optional usage |
| Custom constraints | Annotation processors | State transitions, business rules |
Configure Checker Framework in Maven:
<plugin>
<groupId>org.checkerframework</groupId>
<artifactId>checkerframework-maven-plugin</artifactId>
<configuration>
<processors>
<processor>org.checkerframework.checker.nullness.NullnessChecker</processor>
</processors>
</configuration>
</plugin>
Use ArchUnit to enforce:
*.generated.*.Impl.Example ArchUnit test:
@Test
void generated_packages_are_not_manually_modified() {
JavaClasses classes = new ClassFileImporter().importPackages("com.example");
ArchRule rule = noClasses()
.that().resideInAPackage("..generated..")
.should().beAnnotatedWith(NotGenerated.class);
rule.check(classes);
}
| Layer | Recommended | Alternative |
|---|---|---|
| Framework | Quarkus (compile-time DI) | Spring Boot with AOT enabled |
| Build Tool | Gradle (incremental builds, task dependencies) | Maven with incremental build plugin |
| Specification | OpenAPI + JSON Schema + custom annotations | — |
| Code Generation | OpenAPI Generator + jsonschema2pojo + annotation processors | — |
| Static Analysis | Checker Framework + ArchUnit | Error Prone + SpotBugs |
| Module System | JPMS (Java 9+) | Package conventions (if JPMS not feasible) |
| Constraint | Mitigation |
|---|---|
| Reflection-heavy frameworks (Spring traditional) | Use constructor injection; limit Deep Coding scope to contract layer |
| Bytecode manipulation tools (Lombok) | Avoid; replace with explicit code or MapStruct (generated, visible sources) |
| Existing legacy codebases | Apply Deep Coding only to new modules; incrementally extract structural specifications from legacy code |
| Cross-team coordination | Enforce only interface-level contracts; allow internal implementation flexibility |
interfaceOnly=true.module-info.java and configure exports.