Table drive

Table-driven method:

A programming mode, the information from the lookup table inside without the use of logical statements (if, case).

Simple little table-driven:

Suppose a program, another program needs to process messages sent, the message type is a string, each message requires a function for processing. The most basic treatment:

According to table-driven design ideas, it can be designed:

 More complex table-driven:

Consider a message (event) of the drive system, the system need to communicate certain modules and several other modules. After it receives the message, the sender of the message as necessary, the type of message, its status, different treatment.

The more common practice is to achieve a switch with three branches cascade is achieved by hard-coded:

Table-driven method is achieved: According to the definition of the three enumerated: module type, the message type, the state of the self-module, a definition of jump table function

 

 

Guess you like

Origin www.cnblogs.com/tongyishu/p/11682115.html