Software Design Solutions
User Interface Design Specifications
User interface: Also known as the Human machine interface, to achieve communication between the user and the computer to control the computer or the user and the computer between the data transmission system components.
GUI: A graphical user interface, a visual user interface that uses a graphical interface instead of a body interface.
The system adheres to the GUI design principle, the interface is intuitive and transparent to the user. User contact software after the interface of the corresponding functions at a glance, do not need much training can be easily used in this application system.
1. Introduction of Interface Design
Interface design is to meet the requirements of software specialization standardization of the use of the software interface to beautify the optimization of the Standardization of the design branch.
1) software start cover design
Should make the software start cover end for high-definition images, the choice of color should not exceed 256 colors, the size of more than the mainstream display resolution of 1/6 large. The launch cover should be prominently marked with the production or support of the company logo, product trademarks, software names, version numbers, URLs, copyright notices, serial numbers and other information to establish the software image, user or purchaser to be prompted when the software starts. Illustrations should be used with independent copyright, symbolic strong, high recognition, visual communication effect of good graphics, if the use of photography should also be digital processing to form the personalized characteristics of the software. If it is a series of software will also consider the overall design of unity and continuity.
2) Software Framework Design
Software frameworks are much more complex to design. The design of the software framework should be concise and simple, as little as possible with unnecessary decoration, should consider saving screen space, the size of various resolutions, the State and principle of scaling, and for the future design of buttons, menus, labels, scroll bar and status bar reserved location. The overall color combination in the design of a reasonable collocation, the software trademark in a prominent position, the main menu should be placed on the left or top, scroll bar on the right, the status bar is placed below to meet the visual process and user psychology.
3) software button design
The software button design should be interactive, that is, there should be 3 to 6 status effects: When the mouse is not placed on the top of the state, the mouse on the above but not click on the state, click on the status of the mouse is not placed on the top of the state, not click on the state, independent automatically change the state. button should have a concise graphic effect, the name is easy to understand, with accurate words, can hope the text to understand the best, so that users have a functional correlation reaction, the group button should be style unified, the function of the button should be different.
4) Software panel design
Software panel design should have a zoom function, the panel should be clear on the functional interval, should and dialog boxes, pop-up boxes and other styles to match, as far as possible to save space, easy to switch.
5) Menu Design
The menu design is generally checked and unchecked, the left side should be a name, and the right side should be a shortcut key. If there is a subordinate menu should have a lower arrow symbol, the different functional areas should be separated by lines. Menus that are not related to the operation are handled in a shielded manner, and if dynamic loading is used, only the menus that are required are best displayed. The main menu width to be close, the word number should not be more than four, each menu Word can be the same best. The number of main menus should not be too much, preferably a single row layout.
6) Label Design
Label design should pay attention to the change of the corner section, the status can refer to the button.
7) Icon Design
Icon design color should not exceed 64 colors, the size of 16x16, 32x32 Two, should be focused on the visual impact, it needs to show the connotation of the software in a very small range, the use of simple colors in the design, using the eyes of color and dot space mixing effect, make wonderful icons.
8) scroll bar and status bar design
Scroll bar is mainly for the regional space fixed size of the transformation of the internal capacity of the design, there should be up and down arrows, scrolling, and some of the flip-mark. The status bar is for displaying and prompting for the current state of the software.
9) Installation process design
The installation process is designed primarily to beautify the software installation process, including the ability to graphically visualize the software.
10) Packaging and commercialization
Finally, the packaging of software products should consider the protection of good software products, function of the promotion of integration in aesthetics, you can print part of the product introduction.
2. Interface design principles
1) Ease of use
(1) Complete the same or similar functions of the button with frame frame up, commonly used buttons to support shortcuts;
(2) The elements that complete the same function or task are placed in a centralized position, reducing the distance of the mouse movement;
(3) According to the function of the interface divided into local blocks, framed by frame, and to have functional description or title;
(4) The interface to support the keyboard auto-navigation button function, that is, press the TAB key automatic switching function;
(5) The number of controls on the same interface should not be more than 10, more than 10 can consider using a paging interface display;
(6) Paging interface to support the quick switch between pages, commonly used combination shortcut key ctrl+tab;
(7) The default button to support enter and select operation, that is, press ENTER to automatically perform the default button corresponding operation;
(8) The writable control detects the illegal input should give a description and can automatically get the focus;
(9) The Order of the TAB key is consistent with the order of the control, currently popular from the top to the bottom, from left to right way;
(10) check box and option box to have the default options, according to the choice of the probability of the high and low and ranked, and Support tab selection;
(11) When the interface space is small, use the drop-down box instead of the option box;
(12) Use the option box when the number of options is low, instead use the drop-down list box;
(13) Appropriate use of relevant professional terminology, promote the use of universal wording.
2) Normative
The interface design is usually designed according to the specifications of the Windows interface, which includes the standard format of "menu bar, toolbar, tool compartment, status bar, scroll bar, right-click shortcut menu". Small software generally does not provide a tool compartment.
(1) The icon in front of the menu can visually represent the operation to be done, the common menu should have command shortcuts;
(2) to complete the same or similar functions of the menu separated by horizontal line in the same position, the menu depth is generally required to control up to three levels;
(3) The same or similar functions of the toolbar together, each button in the toolbar to have prompt information;
(4) The system is used to set the default location of the toolbar, the toolbar icon can visually represent the action to be done, a toolbar length can not exceed the screen width;
(5) tool bar too long can consider using the tool compartment, tool compartment to have the ability to increase or decrease, by the user to customize according to demand, the default total width should not exceed the screen width of 1/5;
(6) Status bar to be able to display the information users really need, commonly used are: the current operation, system status, user location, user information, prompt information, error information, such as height to place five good words appropriate;
(7) The length of the scroll bar should be based on the length or width of the displayed information can be changed in time to facilitate users to understand the location and percentage of information displayed, and the width should be slightly narrower than the status bar;
(8) The menu and the tool bar must have the clear boundary, the menu request protrudes the display, thus still has the three-dimensional feeling when the tool strip is removed;
(9) Font number fifth is usually used in menus and status bars. The tool bar is generally wider than the menu, but not too wide, otherwise it looks very uncoordinated;
(10) The right-click shortcut menu uses the same guidelines as the menu.
3) Rationality
The diagonal intersection of the screen is where the user looks directly at the top One-fourth places where the user's attention is easily drawn, and the two locations should be taken care of when placing the form.
(1) The center position of the parent form or main form should be near the diagonal focus;
(2) The subform position should be in the upper-left or middle of the main form, and the multiple child forms should be shifted to the right and downward to show the title of the form.
(3) Important command buttons and the use of more frequent buttons to be placed in the eye-catching position on the interface;
(4) buttons that are not related to the in-progress operation should be masked (grayed out in Windows and cannot be used with this button);
(5) For operations that may cause data to be unrecoverable, a confirmation message must be provided to give the user the opportunity to opt out.
4) Aesthetics and coordination
(1) button size is basically similar, and the size of the interface, space to coordinate, avoid using too long name;
(2) Avoid the Open interface to place a large button, the interface should not be placed after the control of a large vacancy position;
(3) The foreground and background color collocation reasonable coordination, contrast should not be too big, the best less with dark, common color consider using Windows interface tones;
(4) The interface style should be consistent, the size of the word, color, font to be the same, unless it is necessary for artistic processing or special requirements of the place;
(5) If the form supports minimizing, maximizing, or zooming in, the controls on the form will also be scaled with the form;
(6) For the interface containing the button should not generally support the zoom, that is, the upper right corner only closed function;
(7) The subform does not need to be scaled when the parent form supports zooming.
5) Interface Consistency
In the interface design should maintain the consistency of the interface. Consistency includes both the use of standard controls, and the use of the same information presentation methods, such as the font, label style, color, terminology, display error messages and so on to ensure consistency.
(1) Display information consistency
① label Hint: The font is not bold, Arial, black, gray or transparent, borderless, right-aligned, without colon, the general situation is fifth;
② Date: Normal font, song body, white black word;
③ Alignment Method
Left-Justified: general text, individual numbers, dates, etc.
Right alignment: Number, time, date and time
④ resolution 800*600, enhanced color 16 color;
⑤ font default is song body, fifth, black;
The ⑥ background is grayed out by default.
This information is arranged to display the style for reference, in the same software should pay attention to the consistency of the form of expression.
(2) Rationalization of layout
Attention should be paid to the layout of all controls within a window and the artistry of the organization of information, making the user interface aesthetically pleasing. Layout should not be too dense, nor too empty, reasonable use of space.
Press the TAB key in a window to move the order without clutter, first from top to bottom, then from left to right. Controls that should be entered first in a screen and important information should be in the tab order, and placed in a more prominent position on the window. The layout is simple, orderly and easy to operate.
(3) Mouse and keyboard corresponding
The function in the application should also be done with the keyboard, which should include some necessary buttons and menu items in the design application. However, many mouse actions, such as double-click, drag objects, and so on, can not be easily simulated with the keyboard can be achieved. For example, when you click one of the items in a list box to select the item, you must define a button in the window that represents the selection to be used as a replacement for the Click Function, in order for the keyboard to do the same. If you have two data windows in a window, you can drag one item out of one data window and put it in another, and if you just use the keyboard, you should set the copy or Move menu item in the menu.
(4) Shortcut keys
Using shortcut keys in a menu item allows users who use the keyboard to operate faster, and the use of shortcuts in Windows and its applications is mostly consistent. The shortcut keys applied in this system must be consistent in the semantics of each configuration item.
Ctrl-o Open Ctrl-tab Next window
Ctrl-s Saving Ctrl-esc Task List
Ctrl-c copy ctrl-f4 Close window
Ctrl-v Paste Alt-f4 End App
ctrl-d Delete Alt-tab Next app
Ctrl-x Cut Enter default button/Confirm action
Ctrl-i Insert ESC Cancel button/Cancel operation
Ctrl-h Help SHIFT-F1 context-sensitive Help
Ctrl-p Printing
Ctrl-w off
Other shortcut keys
Other shortcut keys use the initials of Hanyu Pinyin, and the ones that are not commonly used can have no shortcut keys.
6) Wizards
For some parts of the application process is fixed, the user must enter the operation information in the order specified, in order to make the user's operation to get the necessary citation should use the wizard, make the user use the function is easier to understand, but the wizard must be used in the fixed processing process, and the processing process should be not less than 3 processing steps.
7) User Help
The system should provide detailed and reliable help documentation that can be used to find solutions when users are confused.
There are two common types of help facilities: integrated and additional. The integrated Help facility was first designed in software, and it was context-sensitive, and the user was able to directly select topics related to the actions to be performed. The integration of help facilities can shorten the time for users to get help and increase the friendliness of the interface, and additional help facilities are added after the system has been built, usually a weaker online help.
(1) The performance introduction and description in the Help document should be consistent with the system capability;
(2) The operation to provide timely call system help function, commonly used F1;
(3) It is best to provide the current popular online Help format or HTML Help format;
(4) The user can search for help in the Help index with keywords, of course, should also provide help keywords;
(5) In the help should provide our technical support methods, once the user is difficult to solve their own can easily find new ways to help.
8) error messages and warnings
Error messages and warnings are bad messages that the system gives when a problem occurs, and the information is described in terms that the user can understand.
(1) The information should provide constructive advice on how to recover from the error;
(2) The information should indicate what undesirable consequences may be caused by the error, so that the user can check whether these conditions have occurred and help the user to correct them;
(3) Information should be accompanied by visual cues, such as special images, colors or information flashing;
(4) information can not be judged color, that is, in any case can not accuse the user.
9) General Interaction
(1) Consistency: Menu selection, data display and other functions should use a consistent format;
(2) Provide meaningful feedback;
(3) allow the cancellation of most operations on data entry;
(4) Reduce the amount of information that must be remembered between actions;
(5) Allow the user to be non-malicious error, the system should protect itself from fatal error damage.
10) Data Entry
(1) Minimize the number of user input actions;
(2) Maintain the consistency of information display and data input;
(3) The interaction should be flexible and provide support for keyboard and mouse input flexibility;
(4) Making inappropriate commands ineffective in the context of the current action.
11) Uniqueness
If you blindly follow the industry's interface standards, you will lose your personality. In the case of the framework conforms to the specification, the design has its own unique style The interface is particularly important, in the commercial software circulation has the very good imperceptible advertisement utility. The installation interface should have an introduction to the unit or product description, and have its own icon.
General principles of programming specifications
1. Typesetting
1) The program block to be written in indentation style, indentation of the number of spaces is 4, for the development tool automatically generated code can be inconsistent;
2) The relative independent program block, the variable description must be added blank line;
3) A long statement to be divided into multiple lines of writing, long expression to the lower priority operator to divide the new line, the operator placed in the first line of new lines, the new line is divided into appropriate indentation, so that the layout is neat, the statement can be read;
4) If there are longer expressions or statements in the circular, judgment and other statements, the Division of adaptation shall be divided into 3);
5) If the parameters of the function or process are longer, they should be properly divided;
6) do not allow multiple phrases to be written in one line, that is, a single line of writing a sentence;
7) If, for, does, while, case, switch, default, and other statements from a row, and if, for, do, while and other statements of the execution of the statement part of any number of parentheses {};
8) Align only use SPACEBAR, do not use Tab key;
9) The beginning of the function or process, the definition of the structure and the loop, judgment and other statements in the Code are to adopt the indentation style, case statement under the processing of statements to comply with the statement indentation requirements;
10) The delimiter of the block (such as curly braces ' {' and '} ') should be exclusive for each row and be in the same column, and aligned to the left of the statement referencing them. At the beginning of the function body, the definition of the class, the definition of the structure, the definition of the enumeration and the procedures in the If, for, do, while, switch, case statements shall be indented as above;
11) in more than two keywords, variables, constants for peer operation, between their operators before, after, or before and after a space, but do not leave more than two spaces in a row. When you do a non-peering operation, you should not add a space after a closely related operator, such as.
The purpose of this loosely written code is to make the code clearer, and there is no need to leave spaces in the already very clear statement. If the statement is clear enough, the inside of the parentheses (that is, before the opening parenthesis and the right parenthesis) does not require a space, and no space is added between the braces. In a long statement, if you need to add a lot of space, then you should keep the overall clear, and in the local without space.
(1) commas and semicolons are only appended with spaces.
int A, b, C;
(2) Comparison operators, assignment operators, arithmetic operators, logical operators, bitwise operators and other binocular operators before and after the space.
A = B + C;
A *= 2;
A = b ^ 2;
(3) "!", "~", "+ +", "--", "&" (address operator) and so on, no space before and after the monocular operators.
flag =!isfull;
p = &com;
i++;
(4) ",", "." No spaces before and after.
(5) If, for, while, switch and the following parentheses should be added space, so that if the keyword more prominent, obvious.
if (a >= b && C > D)
12) A line program to less than 80 characters is appropriate, do not write too long.
2. Comments
Comments should explain the purpose of the code, to clarify why you should do it, not how to do it. 1) In general, the source program effective annotation amount must be above 20%. The principle of annotation is to help the reading comprehension of the program, in the addition of the place, the comments should not be too much or too little, the annotation language must be accurate, easy to understand, concise;
2) note format as uniform as possible, we recommend the use of "/* ... * *";
3) Descriptive documents (such as header files,. h files,. inc files, etc.) should be commented on, comments must be listed: Copyright description, version number, generation date, author, content, function, relationship with other files, etc., the comments of the header file should also be a brief description of function function;
4) The source file header should be commented, listed: Copyright description, version number, generation date, author, module function, main functions and functions, etc.
5) Function Head should be commented, listed: function function, input parameters, output parameters, return value, etc.
6) Side write code side comments, modify the code at the same time to modify the corresponding comments to ensure that the comments and code consistency;
7) Avoid using abbreviations in annotations, especially for very useful abbreviations. If unavoidable, the abbreviations should be explained as necessary;
8) Comments should be similar to the code they describe, the comments on the code should be placed above or to the right (comments on a single statement) adjacent position, such as placed above the code with the above is separated by a blank line;
9) variables, constants, macro notes are sometimes necessary, should be placed above the adjacent position or to the right;
10) data structure declarations (including arrays, structs, classes, enumerations, etc.), which must be annotated if their names are not fully self-explanatory. Comments on the data structure should be placed in the adjacent position above it, and the comments on each field in the structure should be placed to the right of the field;
11) Global variables to have a more detailed comment, including its function, range of values, which functions or procedures to access it and access to the notes, etc.;
12) Separate the comment from the code above with a blank line, and the comment is indented the same as the described content;
13) The definition of variables and branching statements (conditional branching, looping statements, etc.) must be annotated. These statements are often the key to a program's implementation of a particular function, and for maintenance staff, good annotations help to better understand the program, sometimes even better than looking at the design document;
14) make the code self-explanatory and reduce unnecessary annotations by correctly naming the function or process, variable, structure, etc., and organizing the structure of the code rationally;
15) When the code snippet is longer, especially multiple nesting, the end line of the block is annotated to indicate the end of a block;
16) suggest that the note use Chinese more, unless it can be expressed in very fluent and accurate English.
3. Name of the identifier
1) The name of the identifier should be clear, clear meaning, while using the complete word or basic understandable abbreviations, to avoid misunderstanding. Long words are the first few letters of the word to form abbreviations, some of the words are generally recognized abbreviations;
2) in the name of the use of special conventions or abbreviations, should be at the beginning of the source file, the necessary explanatory notes;
3) The naming style should be consistent from beginning to finish;
4) for variable name, prohibit to take a single character (such as I, J, K ... )。 A single character is easy to knock and is not easy to check out at compile time. It is suggested that in addition to the specific meaning, it can also indicate its variable type, data type and so on, but I, J and K can be used as local cyclic variables.
5) The naming specification must be consistent with the system style used and unified within the same project. Do not use numbers or more strange characters to define identifiers unless necessary;
6) in the same software product, should plan the interface part identifier (variable, structure, function and constant) naming, prevent compile, link conflict;
7) Use the correct antonyms group to name the variable with mutually exclusive meaning or the function of the opposite action;
Here are some of the antonyms groups commonly used in software:
Add/remove Begin/end Create/destroy
Insert/delete Add/delete Get/release
Increment/decrement Put/get
Lock/unlock Open/close First/last
Min/max old/new Start/stop
Next/previous send/receive Show/hide
Source/target source/destination
Cut/paste Up/down
8) In addition to special applications, you should avoid using the following lines of the beginning and end of the definition.
4. Readability
1) Note the precedence of the operators and use parentheses to clarify the order of operations of the expressions, and avoid using the default precedence;
2) Avoid the use of difficult to understand the number, with meaningful logo to replace;
3) The source program is closely related to the code should be as close as possible, easy to read and find programs;
4) Do not use difficult-to-understand, highly-skilled statements unless it is necessary. The efficiency of the program is not the same as the high skill of the statement, but the algorithm.
5. Variables and structures
1) Remove unnecessary public variables to reduce the coupling between modules;
2) Carefully define and clarify the meaning, function, value range and the relationship between public variables;
3) Clarify the relationship between public variables and functions or processes that manipulate this public variable, such as access, modification, and creation. A description of this relationship can be described in a note or document;
4) When passing data to a public variable, be very careful to prevent the occurrence of an unreasonable value or an out-of-bounds phenomenon. If necessary, the legality check should be carried out to improve the reliability and stability of the code;
5) constructs only one module or function can modify, create, while the rest of the module or function access only public variables, to prevent a number of different modules or functions can modify, create the same common variables phenomenon;
6) Use strictly defined, portable standard data types and try not to use variables that are closely related to the specific hardware or software environment;
7) The structure of the function of a single, is the abstraction of a transaction. Each element in the structure should represent a different aspect of the same transaction, and the elements of different transactions that describe no relationship or weak relationships should not be placed in the same structure;
8) The relationship between different structures should not be too complicated, otherwise modernisms is a structure;
9) Carefully design the layout and order of elements in the structure, make the structure easy to understand, save space, and reduce the phenomenon of causing misuse;
10) The design of the structure should consider forward compatibility and future version upgrade as far as possible, and reserve room for some future possible applications;
11) Pay attention to the specific language and compiler to deal with different data types of principles and relevant details;
12) When programming, be aware of the data type casts. To be fully aware of the default data type conversion of a compiled system, to minimize the unnecessary conversion and casting of data types, to design data reasonably and to use custom data types to avoid unnecessary type conversions between data;
13) Properly name the custom data type to make it self-descriptive, to improve the readability of the code, but pay attention to its naming in the same product unity.
6. Functions and processes
1) design a function with high fan-in and reasonable fan-out (less than 7). The better software structure is usually the top-level function of the fan-out is higher, the middle function of the fan-out less, and the underlying function is fan into the public module;
2) The size of the function should be limited to 200 lines, excluding comments and blank lines;
3) The error return code of the called function should be handled carefully and comprehensively;
4) in the same project team should clearly stipulate that the validity of the parameters of the interface function check should be the function of the caller responsible or the interface function itself, the default is the function caller responsible;
5) Prevent the parameters of the function as working variables. For the parameters that must be changed, it is best to use local variables for the first time, and then assign the contents of the local variable to the parameter;
6) A function only completes one function, do not design multipurpose functions. Function names should accurately describe function functions;
7) functions should be predictable, that is, the same output should be produced as long as the input data is the same;
8) Avoid the design of multi-parameter functions, not the use of parameters removed from the interface, reduce the complexity of the interface between functions;
9) The non-dispatch function should reduce or prevent the control parameters, try to use only data parameters, prevent the control coupling between functions;
10) Check the validity of all parameters input and non-parametric input of function;
11) When programming, often encounter the use of the same code in different functions, many developers would like to put this code, and form a new function. If the code is large and it is done with a function, then this construct is reasonable, otherwise the structure will produce a function of random cohesion;
12) function ambiguous and smaller functions, especially when only one superior function calls it, should consider merging it into the higher function, rather than having to exist alone;
13) Reduce the function itself or recursive calls between functions. Unless the implementation of some algorithms or functions is convenient, the unnecessary recursive calls should be reduced;
14) Carefully analyze the function and performance requirements of the module, and further subdivision, if necessary to draw the relevant flow chart, according to the function of the module division and organization;
15) for a function that provides a return value, it is best to use its return value when referencing;
16) When a procedure (function) has more references to a longer variable (usually a member of a struct), you can replace it with a macro that is quite meaningful.
7, the Testability
1) in the same project team or product group, a set of unified test and system for the integration of the preparation of the commissioning switch and the corresponding printing function, and to have a detailed description;
2) in the same project group or product group, the format of the information string printed out must be in a uniform form. The information string must be at least in the module name (or source file name) and line number;
3) programming to select the appropriate test points for the unit test, and carefully construct the test code, test cases, and give a clear annotated description. The test Code section should be used as a submodule (in the module) to facilitate the testing of the code in the module installation and disassembly (through the commissioning switch);
4) Use assertions to discover software problems and improve code testability. Use assertions to check that a program should not occur while it is in operation, but that there is an illegal situation that may occur while commissioning, but you cannot use assertions to check for errors that the final product will definitely appear and must handle;
5) Add explicit annotations to more complex assertions, confirm the parameters of the function with assertions, ensure that no defined features or functions are not used, and check the assumptions of the development environment of the program;
6) Formal software products should be asserted and other debugging code removed (that is, the relevant commissioning switch off), in order to speed up the speed of software operation;
7) in the software system to set up and cancel the relevant testing means, can not affect the function of software implementation;
8) Use the commissioning switch to switch between the debug version and the official version of the software, instead of having both the official version and the debug version of the different source files to reduce the difficulty of maintenance;
9) The debug version and release version of the software should be unified maintenance, do not allow separation, and always pay attention to ensure that two versions in the implementation of the consistency of the function;
10) before writing the code, the program should be designed to debug and test the method and means, and design a variety of debugging switches and corresponding test code such as printing functions;
11) The commissioning switch should be divided into different levels and types. For the module or system part of the code of the commissioning, for the module or system of a function of the commissioning, performance, capacity and other testing;
12) Write the error-proof program, and then use the assertion to announce that a fault occurred after processing the error.
8. Program Efficiency
1) Improve code efficiency under the premise of ensuring the correctness, stability, readability and testability of software system, including global efficiency, local efficiency, time efficiency and space efficiency;
2) Local efficiency should be the global efficiency service, not because the local efficiency to improve the overall efficiency of the impact;
3) Improve the space efficiency by dividing and organizing the system data structure and optimizing the program algorithm;
4) Carefully consider whether the statement in the circulating body can be placed outside the circulation body, so that the workload of the circulation is minimal, thus improving the time efficiency of the program;
5) Carefully examine, analyze the system and module processing input (such as transactions, messages, etc.) and improve the way;
6) Analyze and optimize the function in the module, improve the structure of the function in the module and improve the efficiency of the program.
7) should not spend too much time desperately to improve the efficiency of calling less frequent function code;
8) carefully construct or directly use the assembly to write functions that are frequently called or have very high performance requirements. Embedded assembly can improve time and space efficiency, but there are some risks.
9) in order to guarantee the quality of the program, the space efficiency can be improved by compressing the code amount, removing unnecessary code and reducing unnecessary local and global variables.
10) Minimize the loop nesting level. In multiple loops, the busiest loop should be placed on the inner layer to reduce the number of times the CPU has cut into the loop layer;
11) To avoid the loop body containing the judgment statement, the circular statement should be placed in the code block of the judgment statement;
12) Try to use multiplication or other methods instead of division, especially in floating-point operations;
13) Do not blindly pursue the compact code, because the compact code does not represent the efficient machine code.
9. Quality Assurance
1) Build software quality in the process of software design;
2) Code Quality assurance Priority principle
(1) Correctness, refers to the procedure to achieve the design requirements of the function;
(2) Stability/safety, means the procedure is stable, reliable and safe;
(3) testability, refers to the procedure to have a good testability;
(4) specification/readability, refers to the procedural writing style, naming rules, etc. to conform to the norms;
(5) Global efficiency refers to the overall efficiency of the software system;
(6) Local efficiency refers to the efficiency of a module, sub-module and function;
(7) Personal expression means, personal programming habits.
3) only refer to their own storage space;
4) Prevent references to memory space that has been freed;
5) The memory allocated in the procedure/function to be released before the procedure/function exits;
6) The file handle requested in the procedure/function (used for opening the file) and closed before the procedure/function exits;
7) Prevent the memory operation out of bounds;
8) Serious processing procedures can be encountered in various error situations;
9) At the beginning of the system operation, to initialize the relevant variables and operating environment, to prevent the uninitialized variable is referenced, and the data loaded into the system for consistency check;
10) Do not arbitrarily change other modules or systems (not their own) of the relevant settings and configuration, can not arbitrarily change the interface with other modules;
11) Note the easy-to-mix operator. When the program is finished, you should check these operators from beginning to end to prevent spelling errors;
12) If possible, the IF statement is as much as the Else branch and should be treated with caution for statements without the Else branch. The switch statement must have a default branch;
13) Do not use statements that are related to the hardware or the operating system, and use the recommended standard statements to improve the portability and reusability of the software;
14) carefully constructed algorithm, and its performance, efficiency testing, the more critical algorithm is best to use other algorithms to confirm;
15) Notice whether the expression will overflow, underflow, the use of variables should pay attention to its boundary value;
16) The system should have a certain degree of fault tolerance, some error events (such as user misoperation, etc.) can be automated remediation;
17) For some dangerous operation code should be carefully considered, to prevent the data, hardware and other security hazards, in order to improve the security of the system.
10. Code editing, compiling and reviewing
1) with the Product Software (project group), it is best to use the same editor and use the same setup options;
2) Turn on all the alarm switches of the compiler to compile the program;
3) Check the code through the Code of the daytime and the way of review;
4) Write code should be careful at any time to save, and regular backup, to prevent the loss of power, hard disk damage and other causes of code lost;
5) Some statements are compiled to generate an alarm, if you think it is correct, then you should remove the alarm information by some means;
6) Use the Code Checker to check the source program and use the software tool for code review.
11. Code Testing and Maintenance
1) Unit test requires at least a statement coverage;
2) The compiled or optimized code should be reviewed and tested;
3) Code version upgrade to undergo rigorous testing;
4) Use the tool software to maintain the code version;
5) Any modification of the software in the official version should be documented in detail;
6) Find errors immediately modified, and to be recorded;
7) Key code in the assembly level tracking;
8) Carefully design and analyze test cases, so that test cases cover as many cases as possible to improve the efficiency of test cases;
9) As far as possible to simulate a variety of errors in the program, error handling code to fully test;
10) carefully test the code to deal with data, variable boundary conditions;
11) Retain the test information for analysis, experience and more adequate testing;
12) should not pass "try" to solve the problem, should look for the root cause of the problem;
13) Analyze the error of automatic disappearance, make sure how the error disappears;
14) Testing should try to make infrequent events occur frequently;
15) Clarify which events the module or function handles and make them happen frequently;
16) adhere to the coding phase of the code thoroughly unit testing, do not wait for future testing work to identify problems;
17) Remove the randomness of the code run, let the results of the function run predictable, and make the resulting errors reproducible.
Database design Principles
Database technology is the most effective means of information resource management. Database design is the core and foundation of establishing database and its application system, it needs to construct a better database pattern for the specified application environment, establish database application system, and make the system can store data effectively, and satisfy various application needs of users.
1. Before designing the database
1) Understand the needs of customers, ask the user how to view the future changes in demand. Let customers explain their needs, and as the development continues, often ask customers to ensure that their needs are still in the development of the purpose;
2) understand the business, in the future development stage to save a lot of time;
3) Attach importance to input and output. When defining database table and field requirements (input), you should first examine existing or already designed reports, queries, and views (outputs) to determine which tables and fields are necessary to support these outputs;
4) Create data dictionaries and e-r diagrams, which is absolutely necessary for the documentation of SQL expressions;
5) Define the standard object naming specification.
2. Design of table and field
1) Table Design principles
(1) Standardization and standardization;
Standardization of data helps eliminate data redundancy in the database. There are several forms of normalization, but the third normal form (3NF) is generally considered to be the best balance in terms of performance, scalability, and data integrity. In fact, for the sake of efficiency, it is sometimes necessary to not standardize the table.
(2) Adopt data-driven, enhance the flexibility and expansibility of the system;
(3) When designing the database, consider which data fields may be changed in the future.
2) Field design principles
(1) 3 useful fields that should be added to each table;
①drecordcreationdate, the default is GETDATE () under SQL Server;
②srecordcreator, default is not NULL under SQL Server
DEFAULT USER;
③nrecordversion, the recorded version tag, helps to accurately describe the cause of NULL data or data loss in the record.
(2) for address and telephone number of fields, phone numbers and e-mail addresses preferably have their own data tables, with their own type and tag category;
(3) Use the role entity to define the columns belonging to a certain class, create a specific time association, so that self-documentation can be achieved;
(4) Select the number type and text type to be as sufficient as possible, otherwise unable to perform the calculation operation;
(5) Add delete tag field. Do not delete a single row in a relational database, but include a delete tag field in the table so that the row can be marked for deletion.
3. Keys and Indexes
1) Key Selection principle
(1) Key Design 4 principles
① All keys must be unique;
② Create a foreign key for the associated field;
③ avoid using composite keys;
The ④ foreign key is always associated with a unique key field.
(2) using the system-generated primary key to control the database index integrity, and when it has a consistent key structure, it is easy to find a logical flaw;
(3) Do not use the user's key, usually do not select the user editable field as the key;
(4) Optional keys can sometimes be used as primary keys and can have the ability to build strong indexes.
2) Index Use principle
Indexing is one of the most efficient ways to get data from a database, and the vast majority of database performance problems can be solved using indexing techniques.
(1) The logical primary key uses a unique group index, which takes a unique non-group index on the System key (as a stored procedure) and a non-group index on any foreign key column. Consider how large the database is, how the table is accessed, and whether these accesses are used primarily for reading and writing;
(2) Most databases index the auto-created primary key fields, but you cannot forget the index foreign keys, which are also frequently used keys;
(3) Do not index the Memo/note field, do not index large fields, which will make the index occupy too much storage space;
(4) Do not index commonly used small tables, do not set any keys for small data tables, especially if they often have insert and delete operations.
4. Data integrity Design
1) Integrity Implementation Mechanism
(1) Entity integrity: Primary key
(2) Referential integrity
① Delete data in parent table: Cascade Delete, restricted delete, empty value;
② Insert data in parent table: Restricted insertion, recursive insertion;
③ update data in parent table: cascading updates, restricted updates, empty values.
There are two ways that DBMS can implement referential integrity: the foreign key Implementation mechanism (constraint rules) and the trigger implementation mechanism.
(3) User defined integrity: not Null,check, trigger.
2) Enforce data integrity with constraints rather than business rules;
3) mandatory indication integrity. Remove the harmful data before it enters the database, and activate the indicator integrity of the database system;
4) The best way to control data integrity by using lookup to control data integrity is to limit the user's choice;
5) Adopt a view. You can create a dedicated view of your application without having to access the data tables directly from the application, which is also tantamount to providing you with more freedom when working with database changes.
5. Other Designs
1) Avoid the use of triggers, it is really necessary to focus on the documentation of it;
2) use common English (or any other language) instead of coding, and you can attach the user-known English to the code, if you really need it;
3) Save common information. Having a table dedicated to general database information enables a simple mechanism to track the database, which is especially useful for non-client/server environments.
4) includes version mechanism, it is more convenient to modify database structure;
5) Prepare documentation for all shortcuts, naming conventions, restrictions and functions;
6) Repeated testing, to ensure that the selected data type to meet business requirements;
7) Checking the design, the common technique for checking database design during development is to check the database through its supported application prototypes.
6. Database naming specification
1) Name of entity (table)
(1) The table is named after a noun or noun phrase, and a simple rule is defined for the table alias;
(2) If the name of a table or field is only one word, it is recommended not to use abbreviations, but to use complete words;
(3) All the tables in the stored values list are preceded by a prefix Z to sort the list of values in the database at the end;
(4) The naming of all redundant classes (mainly cumulative tables) preceded by the prefix x. Redundancy class is to improve the database efficiency, non-normalized database when added to the field or table;
(5) The association class is named after the two basic classes are connected by an underscore, followed by an alphabetical list of two table names or abbreviated table names. Association tables are used to hold many-to-many relationships.
2) Naming of attributes (columns)
(1) Using meaningful column names, the columns in the table should adopt a set of design rules for the key;
Each table will have an automatic ID as the primary key, and the logical master is defined as the first set of candidate Masters. If it is a custom logical encoding, it is named with an abbreviated "ID" method. If the key is a numeric type, you can use _no as the suffix. If it is a character type, you can use the _code suffix. A standard prefix and suffix should be used for column names.
(2) All attributes plus the suffix of the relevant type, if additional suffixes are required, are placed before the type suffix. Data type is a field of text, type suffix TX can not write, some types of more obvious fields can also not write type suffix;
(3) Named by prefix. Using a uniform prefix for each table's column names can be greatly simplified when writing SQL expressions, but there are drawbacks, such as the role of the automatic table join tool.
3) Name of the view
(1) The view is prefixed with V, and other naming rules and tables are named similarly;
(2) naming should reflect the functions of each view as far as possible.
4) Naming of triggers
The trigger is prefixed with TR, the trigger name is the corresponding table name plus suffix, insert trigger plus _i, delete trigger plus _d, UPDATE trigger plus _u. such as: Tr_user_i,tr_user_d,tr_user_u.
5) Stored Procedure name
The stored procedure should begin with UP_, distinguish it from the stored procedure of the system, and the following sections are mainly made of the verb-bin form, and the components are divided by underscore.
6) Variable name
Variable names are lowercase, and if they are in the form of a phrase, separate each word with an underscore.
7) Other considerations in naming
(1) The above name shall not exceed the system limit of 30 characters, the length of the variable name is limited to 29 (not including the identity character @);
(2) The names of data objects and variables are English characters, forbidden to use Chinese names, never leave spaces between the characters of the object name;
(3) Be careful to keep the word, to ensure that your field name does not have a reservation word, database system or common access methods conflict;
(4) Maintain the consistency of field names and types, and be sure to ensure consistency when naming fields and specifying data types for them.
Software Design Solutions