Procedure Memorand: Version - Judgment Tree (20040823 20:06)

xiaoxiao2021-03-06  102

There are many software theories very much, and there are many of the theory of other majors. From the waterfall model of software engineering, the code should be done according to detailed design. The judgment tree is a tool for systematic analysis and design, but the coding personnel do not necessarily find clear judgment tree data from the detailed design book. It is assumed that there is a lower coding requirement: there are two state variables, each variable has 4 state values, and there are 4 processing methods for different combinations of the two states. The following encoding can be performed (Java Example). / / -------------------------------------------------------------------------------------------- --------- Public void main_deal (string st1, string st2) {// Take the processing method judgment value string strjudge = getjudge (ST1, ST2); // Process IF ("RET1" is separately processed according to the determination value. Equals (STRJUDGE)) {sub_deal1 ();} else if ("Ret2" .Equals ()) {sub_deal2 ();} else if ("Ret3" .Equals (strjudge)) {sub_deal3 ();} else IF "Ret4" .Equals (STRJUDGE)) {sub_deal4 ();} else {final_deal ();}}

Private string getjudge (string st1, string st2) {string ret = null; // Take the processing method judgment value Return Ret;}

PRIVATE VOID SUB_DEAL1 () {// Sub processing 1}

PRIVATE VOID SUB_DEAL2 () {// Sub processing 2}

Private void sub_deal3 () {// sub-processing 3}

PRIVATE VOID SUB_DEAL4 () {// Sub-processing 4}

Private void final_deal () {// Treatment outside the condition} // -------------------------------- ------------------------- If multiple branches of the program need to complete the same job, you may want to use the judgment of the trees to make a mess, Write a clear and easy-to-understand code. The above example is intuitive, and the actual application may have many clues that are not easy to clarify, and it is necessary to see the essence through phenomenon.

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

New Post(0)