How AI‑Powered Code Generation Cut Java Development Time by 40%
This article details how Ant Group’s international credit team applied AI‑assisted code generation using CodeFuse plugins and custom prompts to automatically transform system specifications into Java façade, persistence, and business‑logic code, achieving a 40% reduction in coding effort across multiple projects.
1. Introduction
The Ant International Credit team faced rapid iteration cycles, strict code‑quality standards, and distributed development, prompting an exploration of AI‑assisted code generation (AI Coding) to improve efficiency and maintain compliance.
2. AI Solution Overview
By extracting core information from system specifications ("系分"), generating task lists, and feeding them to AI tools with carefully crafted prompts, the team aimed to automate Java code creation. The workflow integrates IDEA CodeFuse plugin, CodeFuse IDE, and a custom prompt library.
3. Implementation Approach
3.1 Task Generation
System specifications are parsed to obtain interface definitions, database schemas, and flowcharts. A structured task list (Todo_Task_List.md) is produced, describing material references and execution steps for each module (facade, persistence, business logic).
# Interface List
## User Creation
- Description: User creation
- Service Path: com.xxx.appname.facade.api.user.UserFacade#userCreate
- Request: UserCreateRequest
- Response: UserCreateResult3.2 Facade Code Generation
Two prompt templates are used – one for new interfaces and one for modifications. Prompts enforce architecture rules (Facade, Service, Manager, Core‑Model), coding standards (Sofa RPC, Spring, Lombok), and include complete reference examples to guide the model.
# 1. Role Definition
You are an expert in generating code for the xxx application architecture.
# 2. Core Responsibilities
Generate a complete, production‑ready set of Java files based on the provided interface definition.
# 3. Generation Rules
- Follow nested‑model handling rules
- Include converter classes
# 4. Code Generation Directives
Generate Facade, Request/Result, Impl, Converter, Manager, Model, Service, Repository, and Mapper files.3.3 Persistence Layer Generation
Similar prompts generate DAL, Repository, and Service layers from CREATE TABLE SQL. The model extracts table name, columns, primary keys, and produces MyBatis XML, DO classes, and CRUD methods.
# Role Definition
You are a senior Java backend engineer proficient in DDD and MyBatis.
# Core Responsibilities
Parse CREATE TABLE statements and generate full Java and XML code for DAL, Repository, and Service layers.3.4 Business Logic Generation
Flowcharts (PlantUML) are first enhanced into Chinese pseudo‑code, then fed to the model. The prompt defines parsing rules for gateway calls, DB calls, logging, assertions, SPI calls, and model assembly, guiding the model to produce accurate Java logic while limiting hallucinations.
# Role Definition
You are a Java developer skilled in PlantUML and markdown.
# Core Responsibilities
Convert flowchart content into Chinese pseudo‑code, then generate Java code.
# Execution Steps
1. Extract flowchart steps
2. Translate PlantUML syntax to if‑else/loop structures
3. Apply matching rules (DB call, gateway call, etc.)
4. Output pseudo‑code for AI generation.4. Practical Results
In three real projects the AI workflow generated 2–4 new interfaces, multiple tables, and thousands of lines of code. Adoption rates were 90‑100% with no compilation errors, reducing coding effort by 40% (average 4.5 person‑days vs. 8 person‑days) and shortening overall delivery time to under an hour for many tasks.
5. Code Review and Quality Assurance
Static rule checks (facade path, naming conventions, credit‑domain naming) and dynamic tests (unit, integration, EvoTest‑generated cases) were applied. Violations are reported and fed back to the model for correction.
6. Lessons Learned
Prompt iteration 2‑3 times yields best results; further attempts increase randomness.
Clear, unique task titles improve material extraction.
Providing concrete code examples dramatically improves output quality.
Defining inference boundaries and constraints reduces hallucinations.
7. Future Directions
Plans include tighter integration with MCP Server for rule storage, workflow‑driven configuration generation, and a closed‑loop of design‑code‑test‑feedback to achieve fully autonomous Java development.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Developer
Alibaba's official tech channel, featuring all of its technology innovations.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
