May 4th Movement of the new century: the vernacular procedures (1)
RAD development tools familiar with the students all know, see "predecessors" "legacy" from the procedure is a pain. Change these procedures is a more painful. And changed the course of the proceedings, measured by the number of "prehistoric mistake," is suffering in pain. Koujian small matter, in one breath swallow it down, the taste bad enough to be wronged. Therefore, the students have changed in the process of carefully, global variables can not be fixed, it's clear that the original change to a function can meet the requirements, it is still a relatively write their own insurance. Who knows where will turn over a time bomb?
As a result, more and more complex procedures, more and more bloated. Development of a head of countermeasures, each team responsible for a certain number of modules, long time, know their own roots Zhide, the courage to surgery procedures on their own. However, staff mobility, staff stay is inevitable things, a person responsible for a fixed number of long-standing procedures difficult. Set aside these aside, the students of a certain assumptions in the company is responsible for maintenance of a limited number of modules, he of the development to speak of?
Therefore, in the final analysis, we have to make procedures easy to understand, easy to modify, easy to expand, is the ultimate goal. Everything is hard in the beginning, we should first start with ourselves.
First look at the others. Procedures, in the end is what hinders their reading and revision?
1, global variables.
î—± î—± global variables is a disgusting things. Assume that we are now seeing here is a:
î—± î—± mbDisplayInPrice: Boolean; / / indicate that the purchase price î—± î—± Logically, the style very good, Notes, prefix, the name has also been good. However, the variables it did not have a "master" If we say that it is kind of document attributes: TReceiptInfo.DisplayInPrice, we can understand that if it is the kind of system parameters attributes: TSysParams.DisplayInPrice, we understand it, but now it is belong to the whole process, so we actually do not know the exact scope of the role.
î—± î—± Therefore, the problems associated with global variables that it does not have the exact implications are often misunderstood, it does not belong to any object in the whole process was likely to be revised everywhere.
2, code distribution in the different regions.
î—± î—± assumption that we have to revise the examination process orders such a function code. In line with our usual understanding, this is a very single function, we should realize this:
    check user privileges       ↓
   -tested user input       ↓
 SQL user input as the input parameters       ↓
î—± î—± î—± î—± called SQL
      ↓
î—± î—± inspection SQL operating results î—± î—±
î—± î—± These procedures, if relatively short, it should be a completion of the process. If a longer, it should be divided into several completion of the process, but by the same function call, so that we can see clearly understand.
î—± î—± However, in our procedures there, check user privileges in the controls inside to achieve, and-tested user input may be placed inside Query.BeforePost inspection, SQL is written in the form of paper inside (of the day to know which procedures will be conducted SQL handling, for example, with what authority procurement group), ApplyUpdate in Query.AfterPost incident inside completed, the initial value of certain fields may be given in Query.AfterInsert incident, we may Query.OnNewRecord incident, and may even in the database Trigger do.
î—± î—± In other words, we check this period procedures to a variety of places to look at to change, really painful ah. Of course, if we have a function called UpdateOrder call to unify these processes, it can help to understand how much, but wait a minute, there is a case involving the incident to call the controls, Query1AfterPost is Query1AfterPost, it is not called the private method CommitQuery1 Therefore, it is likely to contain inside the other code (except ApplyUpdate and CommitUpdate), you change it, it may be a time bomb planted.
3, the incident traps î—± î—±
î—± î—± now inside the detailed design document has basically seen a flowchart. From the painting because no flow chart. Event-driven, interface-driven RAD method to subvert our programming method.
î—± î—± remember writing DOS procedures, the program flow is very simple, because that is just a line, a maximum of cycles, there is a statement to the conditions, procedures lucid, code optimization is easy.
î—± î—± then that stresses user interaction, it is true ah, procedures went to the middle of the needs of the user, in the screen display messages to users by y or n, and then run down, but actually it is the conditions to the statement.
î—± î—± to the Windows era, RAD times, the situation is completely different. We assume that in accordance with the idea of DOS program designed to change order process.
    users press the button change order         ↓
    prompts the user to enter orders,         ↓
    pop-up orders, schedules allow users to choose         ↓
  users select a breakdown, the system shows the volume and price changes box, users modify         ↓
î—± î—± î—± î—± pop-up orders schedule allows users to choose (repetition)
        ↓
     end user operating         ↓
î—± î—± î—± î—± î—± submitted revised procedures
î—± î—± But in fact, this process is in no way constructed. Orders in the beginning there, you do not press the amendments to appear. Enquiries conditions input box is always there, not only for you choose there. You can freely in the DBGrid inside a mobile record, despite what is not followed. You can enter search criteria, then delete an order, despite what these two movements not related.
î—± î—± usually in the Qty Price and field events inside the Onchange rewrite Amount values, and now we know that this is not clear code caused one of the reasons why. Call because of this process, the user should be revised after the details, but why do not we on here? Oh, because it controls and the use of standardized Query is not commensurate with the Query controls, in other fields OnChange incident has changed is the value of the recommended wording. Look at our procedures to resolve specific problems, issues Query address conventional controls. Query the incident will not affect the definition of its own code standardization, however, the impact of our procedures code norm.
(To be continued)








0 Comments to “May 4th Movement of the new century: the vernacular procedures (1)”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.