sa*****@yahoo.co.in wrote:
Hi,
I came to read this particular statement with respect to reducing the
complexity of a code,
The usage of functional maps matrices instead of switch statements
should be considered.
I didn't understand what the term functional maps matrices mean? and
for people who are not aware of McCabe's Cyclomatic Comlexity tool,
here is a link with a simple explaination,
http://www.teaminabox.co.uk/download...omplexity.html
Kindly reply as soon as possible.
I expect, that as someone else has noted, the term "functional maps
matrices" refers to the table or matrix representation of a finite
state machine. Basically the column headings are inputs that the FSM
acts on, and the row labels are the possible states of the machine.
Each cell of the matrix contains an action to perform and a transition
to some other state. Suppose I want to read in a number with a decimal
point, but I want to note an error if there is either some character
other than a digit, or a second decimal point before the number is
fully entered: in an obvious notation the matrix would look like
input: other dp digit
state | ------------------------------------------
---------------------------------------------------
0 | error1 >2 | accept >1 | accept >0
1 | error1 >2 | error2 >3 | accept >1
2 \\ abnormal termination -- bad char
3 \\ abnormal termination -- two dp's
Changing the state label to 2 or 3 is a convenience for tracing
which kind of error was made and deciding what to do at that point.
There are even (simple) ways to include counts so that no more
than a certain number of digits are accepted, etc.
The above is easily implemented in C (with switch), Forth, Lisp or
any object-oriented language. It can even be done without excess
trouble in Fortran or Basic using computed or assigned GOTO's.
--
Julian V. Noble
Professor Emeritus of Physics
http://galileo.phys.virginia.edu/~jvn/
"For there was never yet philosopher that could endure the
toothache patiently."
-- Wm. Shakespeare, Much Ado about Nothing. Act v. Sc. 1.