Enterprise application development structure talks (3)

zhaozj2021-02-11  269

As a developer, I have dreams in many years, there is a program that can write many programs so that how much time can save in the system development process.

I have always been a very lazy person, writing a program generator makes me feel a lot of fun. Through him, I saved many repetitive labor, which greatly accelerated the development process. The program generator is highly efficient, and many of the links in development software can be significantly older: data persistence, interface, middleware, etc.

$: Why does I need a program generator?

I have no in-depth research, so I can't talk about this problem. However, from my experience, there is still the following points:

1: Abstract hierarchical standard system. Imagine the following by generating a code, you can standardize the code details such as technology, algorithm, data structure, and completely mask the upper developer. If you need to modify the implementation, you only need a simple modification to definition.

2: Work division works in a large-scale software development, developers often need to jointly maintain code, causing personal independence to work. The program generator provides the developer's effective solution for developers.

3: You can generate a series of products You can generate a range of related products, such as test cases, user documents, charts, other related code, and more.

4: The approves are made by the same issue, and become a specific system, not just a single specific system. For example, you can use the same interface specification (XUL) to generate different platforms (Windows, UNIX) implementations.

5: The correctness and consistency even if you have a developer who has been developed for many years, have you confident on the code written by yourself? By generating the way, it can be greatly reduced. Software development reconstruction is inevitable, but this often triggers new mistakes, program generators, make many modifications, and modify the abstract specification, thereby reducing the modifications thrown.

6: Optimize your performance can be said to the program generator, so that you have more time to waste in the duplicate encoding, there is time to pay attention to the performance of the system.

$: Understanding the three variability of the program.

There are three variability: 1. Runtime variability; compile time variability; time variability.

Running variableibility

The runtime variable information is saved in an external file and read it through the program. In the Castor JDO, it is performed by reading the object relationship map information saved in the configuration file. The configuration in the previous article is both this way.

Compiled time-consuming

Compile information to the program at compile time. Implementation by collaboration with classes.

Digital time

Read the information through a custom program generator read. Sun's JDO specification is both this way. Read the configuration information into the program through the code enhancer. Generate new code.

$: Code Style

There are no two identical leaves in the world, and the same developer's code is different in detail and structure, and the generation generated by the generator should be easy to maintain, easy to understand, easy to modify. Therefore, we need to understand that generation and handwriting needs to follow different rules.

Rules 1: Designed for modifications. The generated program is not important, and it is important that norms, no one will read the procedures you generated, he should be shielded. Rule 2: The correctness of the program. Rule 3: More attention performance rather than readability and structure.

The code generated by the program generator is strictly three styles: 1: object-oriented drive to organize the structure of the program. Functional decomposition. Easy to understand. ................................. ........... ........ .............................. public class topframe extends Jframe IMPLEMETNS ACTIONLISTNER {........ .......................

Public void actionperformed (ActionEvent E) {new jugger (). stop ();} ............................

}

Public class jugger {public class jugler {public synchronized void () {}} 2: Code-oriented drive intuitive, simple output code needs to increase the information obtained from the required specification, the code structure is compact, from handwriting point of view, inconvenient to modify But the dynamic output is not available. Class Afrmae Extneds frame {.............................. public void entry () {ix (prop == start) {start () } Else if (prop == End) {end ();} else if (prop == susnd) {suspend ();} else {system.exit (0);}} .... ...................}

3: Data-oriented drive data is separated from the code, the specification information is stored in a specialized data structure, and the code is restored to the data structure at the time.

Class Employee {

private int id; public void setId (int newId) {this.id = newId;} public int getId () {return id;} private String name; public void setName (String newName) {this.name = newName;} public Stirng GetName () {Return Name;}} int ID ID string name name ===>

Class Data {// Table Data. . . . Public String [] Field = {"ID", "name"}; public string key = "id"; public string Tablename = "EMPLOYEE";

Class Employee Implements Persistence {Class Data {// Table Data. . . . Public final static string [] field = {"id", "name"}; public final static string key = "id"; public final static string Tablename = "EMPLOYEE";} // ......... ...............

private int id; public void setId (int newId) {this.id = newId;} public int getId () {return id;} private String name; public void setName (String newName) {this.name = newName;} public Stirng GetName () {return name;} public string gettablename () {data.tablename;} public string [] getfield () {..................} .. ...........................}

Class Dao {

Public MakePersistence (Object O) {..... SQLStart = "INSERT INTO" GetTableName ("; int count = o.getfield (). Length ();

For (int i = 0; i

There are two ways to generate the code: source code and bytecode. The code generated by the former is the source code. The latter is enhanced on the basis of bytes. I call the former as a white box method, because for the developer to see the structure inside the code, the benefits are easy to implement, nothing is transparent, not easy to shield; the latter is a black box method, generating code is opaque It is not easy to implement, it is not easy to implement, and it is necessary to master additional APIs (BCEL libraries).

This chapter is over.

转载请注明原文地址:https://www.9cbs.com/read-4475.html

New Post(0)