Data Bus - The Soul of the Platform

zhaozj2021-02-16  61

People who use C developers, the function is definitely love and hate: as the process language, the function improves the program's conditioning, facilitating maintenance; the parameters of the programming function make people sickness, if the parameters are a lot, Write a long parameter list, change it to always get long, (as a verification function, only two parameter names, passwords at the beginning), then expand the permissions in the C language declaration and definition part It is really troublesome together. When the parameters are less, they can endure, more times (if they will receive the front desk data into the child function), it is unbearable. So some time you will write a super long function to avoid passing parameters to the subfunction. However, the code written in this is extremely maintenanceability (ask several programmers who do not have a long function of several thousand lines of code).

In fact, the solution is there, and is very ordinary, just add extra code. It has been developed by the Middleware Tuxedo's FML (32) to know that Tuxedo maintains a large buffer area, and the programmer can obtain the value by the variable ID and change the value. From the front desk to the background, a pointer (buffer), only the parameters of the pointer to the buffer is only transferred in most of the background functions. Further, if this buffer is declared into a global, and the final programmer does not need to see more and hateful pointers. It is true that there will be some other issues (described later), but the structure is structural, and reads can be greatly improved. If possible, both the front and backsteps use this way, the transparent transmission of data, the general developers don't have to care about what middleware, pointer, as long as the name (such as "operator name") can be found, change the corresponding Value. There is no need to write out the value from this Form on this Form to the form of an Edit control on this Form, and the information flow required to set up the back office program; if you don't have to point the pointer finger to what happiness in the background program.

Just one name.

Yes, just a name. If the format of the information flow changes, if the FML is changed to XML, it only needs to change the format generation rules, which is quick and convenient. Here is TUXEDO as an example. In fact, if you provide a platform to do this, you don't need to consider the specific implementation form (the cattle can write a similar buffer management library), and some other benefits, no longer listed.

Of course there will be some problems:

1. Name confusion. Different modules, the variable naming of the function must control, otherwise the same problem with excessive use global variables is not a variable, that is, the variable is used, in all, the variable is confusing.

2. Lack of access control. The data bus is equivalent to global variables, any function can access the variables, and if it is not intended to change, an inexplicable error will occur.

3. The efficiency will decrease. Current hardware can endure these losses.

Preliminary resolution assumption:

Increase access control, the data bus is divided into program level and transaction level, and the program level is never released in this process, and the transaction level bus only in a small transaction module. If possible, you can lock some variables before the function is accessed, and the loss is reduced.

Related questions See all Chinese articles in Blog

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

New Post(0)