Establish development programming mechanism

zhaozj2021-02-08  228

Establish a programming mechanism

For systems, the mechanism is a system designed; for a single question, the mechanism is a method of solving problems. This article describes how the mechanism is established and operated in an example. (Mechanism can also be referred to as a pattern, but the mechanism is slightly with some management control aspects)

During the previous programming, although it is divided by module, or in accordance with the object, it has never considered the concept of establishing a problem solving mechanism. Due to this software project, the developer is a few, no longer a person's thing, so, many methods of cooperating development have to be considered. To ensure the development of quality and progress, it will face the following difficulties: 1) The level of developers is different and the development habits, how to play personal abilities while unify thinking; 2) The demand analysis and design of the system is impossible Step by step, it is difficult to estimate the impact on each developer after adjusting the system design, and sometimes it may be necessary. How to reduce the design of the adjustment system design on some of the content; 3) The development of the developer is inevitable, how the continuation of technical resources can maintain only detailed documents, regardless of the readability and continuity of the program they own (Let the novice understand the function of each variable or function is still very difficult). 4) When the time progress has been adjacent or the technical difficulty is too large, it is required to simplify the system function, and some partial development has requested the other part to complete the contradiction, how to avoid the situation of such riders. At this time, the establishment of the mechanism is very necessary. This is a programming standard, which is more than just variables, functions, etc., but more is the rules and regulations of many design and writing procedures. For systems, the mechanism is a system designed; for a single question, the mechanism is a method of solving problems.

Here is a simple and effective approach: Step 1: Basic development ideas of unified development groups (ie, basic development mechanisms) 1) Each member must have developed to jointly develop for any unstaged project with a learning attitude. We are all students, even if they have developed such projects for the second time, they have to learn. The group developed together, first of all, to solve the idea. Developing experience and practices are not conclusions, innovative things may be more valuable. Therefore, it is undoubtedly the guarantee of re-examining the prior technology and innovative new technologies. 2) It's not for your own development procedures, but in the development of the future generations, the part of your development is a complete product, and its users are later developers. So, you must consider how your product will give it to other developers to continue to develop or expand the function. 3) No abstract problem solving formula Do not write code If you receive a task, you will write a bunch of code according to your needs. Although the task is completed, this code may follow it: increase or modify the function equal to heavy Do a software. Although the task is clear, the relationship between the needs of the tasks and the possible handling of the demand is not clear, which requires a comprehensive analysis. Please see a simple example: CAD graphics design, point, line, circle drawing editing and data management, requires drawing, click, delete, move, and modify functionality. The following design is fully implemented according to demand: #define dotid 1 #define lineid 2 #define CircleID 3

Struct tdot {long x, y;}; struct tLINE {Tdot Start; tdot end;}; struct tcircle {tdot center; long radius;}; struct tdata {1 = point 2 = line 3 = garden Long TypeId; File: / / Different data type, 1void * data;}; Class TPAper (TData * DataVal; Void Draw (TData * Data) {Switch (data-> typeid) {Case 1: file: // Draw Point 2: file: // Picture Case 3: file: // Painting Round Default:}} void delete (); void move (); bool select (long x, long y); update ();}; ...... Abstract Design of graphical elements: Abstract the common part of the point, line, and circle into a base class, use the virtual function, so that the respective chambers can solve the drawing and operation.

Typedef myDataType Long

Struct rpoint {myDataType x, y;} Class TLINK {file: // data pointer chain definition;} Class TPAPER: PUBLIC TLINK {Virtual Void Draw () {TPAPER * TEMP; TEMP = fisrtdata (); while (TEMP is not over ) {TEMP-> DRAW (); Temp = Temp-> NextData;}} Virtual void delete (); Virtual void move (); Virtual Bool SELECT (long x, long y); virtual update ();}; class tdot : Public TPAper {rpoint croc; void draw () {representation point. File: // Draw a cross cross with croid.x, crood.y} void delete (); void move (); Bool SELECT (long x, long y); update ();} class tline: public tpaper {rpoint Start Rpoint end; Void Draw () {(end.x, end.y) draws a line. File: // (Start.x, Start.y) to} void delete (); void move (); Bool SELECT (long x, long y); update ();} class tcircle: public tpaper {rpoint center; MylengthType Radius; void draw () {The diameter is a circle of RADIUS. File: // is round, half} void delete (); void move (); bool select (long x, long y); update ();} ......

The difference between the two programs: the first paragraph, the initial idea is clear, but when the draw arc or quadratic curve, the program's code will change, and anything needs to distinguish between points, lines, circles, and other categories. When you must check the type data that should be displayed through the Switch statement. This results in an increase in functions or changed operations, and many places must be changed. In the second paragraph, it is difficult to design in the initial design. After analyzing design, the write code has a good extensibility. Increase a circular arc, but only an arc is incremented, and many operations are encapsulated into a class, and there is no significant impact on the external program. If you add a registration mechanism, register the new content to TPAper, which is more likely to be liable, and the system reliability is guaranteed. If you think that the class of this method takes up too much memory space (the virtual function requires space in the class instance), you can create a basic structure: struct rDatabase {TPAper * type; rdatabase * nextddata; void add (rDatabase *); void Remove (RDataBase *);} struct RDot: public RDataBase {MyDataType X, Y;} struct RLine: public RDataBase {RPoint start, end;} struct RCircle: public RDataBase {RPoint center; MyDataType radius;} data picture elements are implemented For a structure, an instance pointer of the respective chains is placed in a TPAper * Type pointer variable, and the DRAW () implementation is: Virtual Void Draw () {TPAper * Temp; RDATABASE * TEMPDATA;

Tempdata = fisrtdata (); while (Tempdata is not end) {TEMP = Tempdata-> Type; Temp-> Draw (); Tempdata = Tempdata-> nextddata;}} After a series of issues, the abstract formula, Even if the program does not implement too much function, we can think that it has completed 90% of work. Because all the contents needed to increase have been mechanified, as long as the arc, quadratic curve, rectangular box, polygon, double line, etc., do not need to know too much, and other developers can be quickly understood in such a clear mechanism. Join its work. In fact, object-oriented design methods are the establishment of mechanisms, but object-oriented is based on type establishment, paying attention to packaging, but mechanism concepts not only considers the establishment of the class, but also considers the establishment of non-class part, even if the program is handled Very unstructured, its mechanism also exists. A class package is not very good but the mechanism is really a good example: the general editor mentioned in the article, in order to implement the editor touch board, we try to design the editor's commonality internally, and let the expansion independently Creating an editor can identify data classes (no derived inheritance). Therefore, a series of interface functions are used. The display interface function is more mechanism: Struct Rdata {file: // Extender defines the long ID; file: // All integers from zero, by char * data; file: // can be text, or It is a graphic, table or control tfont * font;} The content that is currently displayed file: // is an interface function, returning File: // longustomtexTRect (Text, X, Y) FILE: // is the interface function, returning the width of the special content showText (long & x, long & y) file: // Displays the content {RDATA * text; Text = (RDATA *) getWord (); while (text! = Null) {If (Text-> ID == 0) as text, internal display x = mytextout (Text, x, y); //

Else as a special display, external display x = UserDataout (Text, x, y); //

TEXT = (RDATA *) getWord ();}} This mechanism is required to display the content that should be displayed in the current location, such as a picture. (Of course, only such data information is not enough, at least high. But this mechanism is reasonably existing. Other data management mechanisms are in detail). In this example, there is no need to ask the external extension to have a base-based limit, and he only provides an interface function.

Step 2: According to the basic development mechanism of step, the developer is required to provide two documents: Program Description Documents and Programs use documentation. The program description and use the document to leave the project manager at the same time, and the program is handed over to other developers participating in this section using documents. Guaranteed the secret of core technology to provide a mechanism for expanding perfect. Project administrators can also recruit new developers in accordance with progress requirements and funding power, after short-term training, quickly join the development ranks, thus accelerating the progress of the product.

Step 3: Regular reading procedure uses documents, check whether the mechanism has inclusive, flexibility. Check if a specific method: 1) How many cases can be adapted, whether the common situation is fully included, how many special circumstances? 2) If you consider special circumstances, there is no special case whether the mechanism is effective, efficient? 3) There is no current Considering the situation, it will increase whether it is easy; if it is not easy, whether it is easy to add a simple adjustment mechanism? 4) Is it easy to understand whether the mechanism is easy, it is a lot of requirements or difficult to control. After step three, the system changes (or simplified) to the maximum extent, and the logical contradiction between certain parts can be avoided. Step 4: The establishment of excellence and mechanism cannot be reasonable, and the mechanism must be reasonably reflected in the mechanism. In particular, when it began to create a mechanism, the mechanism requires more delicate week.

An example of a CAD command line processing mechanism:

Definition: The command line only performs text commands and prompt information. Menu, toolbar, buttons, hot keys, etc., send commands and data to command lines. Command line operation picture: (take a circle as an example)

Painting Circle Command Line Waiting for Enter Command | Enter Command "C" | Circular Procedure Start <=============== Call the corresponding drawing circle program Send prompt Option ===== ===========> Waiting for the selection option | is a center, the radius circle <=============== transmit to the selected "R" selection of the color Command item "R" =======> Wait for the input radius | Draw circle <=============== Get the end of the radius "========= =======> Wait for input command

A question and answer in the interactive, after the required parameters of the drawing circle, draw rounds. The command line is from the beginning, waiting for the state of the input command. After entering the command, the command line calls the corresponding command execution program according to the input command; in the execution program, if more parameter information is required, send options or needs to the command line. The input command is handed over to the command line; the command line is waiting to select or enter the parameters, return the result to the executing program, if the execute is needed, continue to repeat the interaction with the command line until you can After executing the program command; after executing the command, the control is handed over to the command line; the command line returns to the waiting input command. Through the command line, we can write some command batch text, and when these batch text is pasted in the command line, the command line executes the command. Command Line supports "/" advanced extension features such as default input control. With the mechanism of the command line, implement other status is as simple as text operations. In short, if you design a good mechanism, you can say that you have a reliable core procedure.

Melang

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

New Post(0)