The original link: segmentfault.com/a/119000002…

Diboot DevTools 2.0 has been released, implementing a lean kernel + back-end development assistant. Here is our current code generation part of the design idea to sort out, so that the need for friends to take a few detours.

1. Development trend of programming technology

Watching American Factory recently: In traditional manufacturing, when production line workers are expensive and inefficient, managers are looking for ways to cut costs and increase efficiency, and automation is the solution of choice.

Software engineering, like construction, has its own complexity, but even more complex things like car manufacturing are increasingly automated. Some say programming will be the last industry to be replaced by automation /AI, but that doesn’t mean programmers can rest easy. If a programmer only knows CRUD, he may be one of the first to be replaced. Because substitution is gradual, automation in the software industry may go through code generation, light code, and no code.

2. Design scheme of code generation

2.1 The foundation should be laid before building

Some generators are generated directly without any underlying code, and the result is just like a project written directly by a programmer without any high-level developer encapsulation. As the code volume increases, the maintainability becomes incredibly poor.

Therefore, the foundation is laid before the building is built, and a basic generic kernel is encapsulated to provide the best implementation of common development scenarios, such as CRUD generic processing, lightweight packaging for each layer, common tool classes, etc.

2.2 Ideal scheme for generator

  • The scope of responsibility of a common kernel should be clear, and the functions within the scope of responsibility should be best practices, so as to avoid large and bloated design.
  • Universal kernel to solve CRUD, associated query and other common scenarios, the realization of the most simplified code, reduce the threshold and generator implementation difficulty.
  • It’s easy to use, preferably starting in a development environment and generating code directly into a local IDE project.
  • Interface operation code generation, live, flexible response to requirements (data structure) change scenarios.
  • Data structure drive code, code and data structure linkage synchronization.
  • General-purpose generation that supports repetitive similar functionality.
  • Support parameter configuration to achieve differentiated code generation.
  • If the audience is large, it needs to be based on mainstream technology and database.

3. Java code generation practices

  • Based on Spring Boot 2.x, the most mainstream and efficient development framework
  • General solution of CRUD based on Mybatis- Plus
  • Non-sql solutions that encapsulate the kernel to implement associative queries and other common scenarios
  • The generator is packaged as a Spring Boot starter for dependent boot
  • Provide an operation interface to synchronize data structure and code
  • Lombok and Swagger are enabled
  • Extract database differences, support MySQL, MariaDB, PostgreSQL, Oracle, SQL Server

Diboot simple and efficient light code development framework (welcome star)

If you want to learn programming, please searchCircle T community, more industry related information and industry related free video tutorials. It’s totally free!