AI Coding Practice: From System Design to Code with CodeFuse and Prompts

AI Coding Practice: From System Design to Code with CodeFuse and Prompts

AI-Assisted Java Backend Development — Workflow & Best Practices

image
image

---

Business Scenario

Back-end Java business code generation for a financial-grade system with accelerated iteration cycles.

AI Solution Overview

  • System design analysis
  • Core element extraction
  • Task list generation
  • AI tools with tailored prompts for end-to-end code generation.

Tooling

  • CodeFuse IDE
  • CodeFuse IDEA plugin (manual mode, agent mode, custom instructions)

Key Results

Deployed across 3 iteration cycles:

  • Faster facade, persistence, and business logic generation.
  • 40% reduction in person-days in coding phase.

---

1. Introduction

Challenges:

  • Tight compliance & quality demands amid rapid iteration.
  • Distributed team collaboration bottlenecks & inconsistent styles.

Solution Approach:

Leverage AI-assisted code generation (AI Coding) with CodeFuse + crafted prompts to streamline conversion from system design docs → production-ready Java.

---

2. Implementation Approach

2.1 Objectives

End-to-end AI coding pipeline:

  • Design docs → Java code.
  • Built-in compliance checks against internal standards.
  • Consistent naming, architecture, call patterns.
  • Developer-first usability.

2.2 Current State Analysis

Adoption barriers:

  • Tool familiarity: Most devs prefer raw IDEA coding.
  • Prompt complexity: Crafting prompts can be as time-consuming as coding.

Parallel Inspiration:

Platforms like AiToEarn官网 unify AI generation → publishing → analytics across major social/content platforms. While focused on multimedia, the workflow streamlining principles apply directly to enterprise code generation.

---

3. AI Trustworthiness

Team confidence hinges on:

  • Continuous model updates & improvements.
  • Clear operational workflows.
  • Avoiding one-off internal tools.

---

3.1 Tool Selection

Why CodeFuse:

  • Frequent model upgrades.
  • Key features:
  • Text-to-graphic extraction (from SVG/Yuque diagrams).
  • Manual mode for rapid executions.
  • Custom instructions reducing repetitive copy-paste.

---

3.2 Code Generation Scope & Sequence

Architecture split:

  • Facade layer capabilities
  • External capabilities
  • Business logic orchestration

Sequence:

  • Generate facade layer from API docs.
  • Generate persistence & DB service layer from schema.
  • Build external capabilities code.
  • Link facade ↔ business logic ↔ persistence.

---

3.3 Process Design

Data sources: SA docs with APIs, DB schemas, diagrams.

Module-specific prompts: Avoid “one prompt fits all.”

---

4. Prompt Design Approach

Types:

  • Task-splitting (extracting APIs, DB tables).
  • Flowchart enhancement (pseudo-code conversion).
  • Facade code prompts.
  • Persistence code prompts.
  • Business logic prompts.

Example — Interface Extraction Prompt:

### {Interface Name}
#### Interface Information
- Description: {desc}
- Service Path: {FQCN}
- Request Params: {param} | table
- Response Result: {result} | table
- Nested Models: {model} | table

---

5. Workflow

Phase 1 — Preparation

  • Prompts stored in project dir.
  • Operational guides loaded into CodeFuse custom instructions.

Phase 2 — Steps

  • Write SA: APIs, table defs, workflows.
  • Extract materials + tasks (task_list.md).
  • Execute per task with CodeFuse plugin.
  • Iterate until all tasks complete.

---

6. Facade Layer Generation

Prompt split:

  • New interface generation vs. modification
  • Strict architecture role definition
  • Mandatory structure: Interface, Requests/Results, Implementation, Converters, Manager layer.

Results:

  • ~12 Java files in < 10 mins.
  • High acceptance rate with minor fixes.

---

7. Persistence Layer Generation

Similar prompt pattern:

  • New table vs. update table.
  • Auto-parse SQL → generate DAL ↔ Repo ↔ Domain Service layers.

Results:

  • 700+ LoC in ~10 mins.
  • Strict compliance with architecture templates.

---

8. Business Logic Generation

Flowchart Enhancement

  • Convert PlantUML diagrams → Chinese pseudo-code.
  • Avoid ambiguous “natural language” steps.
  • Add guiding descriptions for unclear ops (e.g., model assembly).

Reasoning Guidance

  • Define reasoning scope, restrict hallucination.
  • Use structured field assignment rules.

Combined Execution:

  • Enhance diagram.
  • Feed into business logic prompt.
  • Validate generated code.

---

9. Code Inspection

Three checks:

  • Static validation: Rules for file paths, naming conventions, domain-specific vocab.
  • Dynamic validation: EvoTest for unit/integration tests.
  • Risk assessment: Contract Comparison Agent vs. SA-defined contracts.

---

10. Lessons Learned

  • Prompt iteration sweet spot: 2–3 tries.
  • Unique titles for extraction anchors.
  • Example code injection boosts accuracy.
  • Balance manual fix vs. regen time.
  • Enhancement layers improve unclear inputs.
  • Scope-limited reasoning reduces hallucinations.
  • Keep prompts structured & concise.

---

11. Real-world Results

  • Project 1: 2 APIs, 2 tables, ~2.3k LoC → 1 hour → 0 defects → PROD.
  • Project 2: 4 APIs, ~2.8k LoC → 45% dev time reduction.
  • Project 3: 35 APIs, 9 tables, ~30k LoC → 80% mech coding time cut.

---

12. Future Direction

  • TDD Integration: Post-gen test cases driving refinement.
  • MCP Server for knowledge base prompts.
  • Seamless SA → task → code → test pipeline.

---

For real-time full+incremental sync: Flink CDC solution

---

Note on AiToEarn

Throughout this workflow, platforms like AiToEarn官网 provide a model for integrating AI generation, publishing, and analytics across platforms (Douyin, Kwai, WeChat, Bilibili, Xiaohongshu, Facebook, Instagram, LinkedIn, Threads, YouTube, Pinterest, X) — valuable for monetizing and sharing both technical and creative outputs.

---

📌 Summary:

By combining module-specific prompts, structured task extraction, diagram enhancement, and strict architecture rules, AI-assisted Java development can yield high-quality, production-ready code while slashing iteration times — especially when paired with publishing/analytics platforms to extend outputs beyond the codebase.

Read more