473,324 Members | 2,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Regarding McCabe's Cyclomatic Complexity

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.

Apr 4 '06 #1
8 3870
sa*****@yahoo.co.in opined:
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

This is a general algorithm, rather than a C question. It is best asked
in comp.programming
--
There was a young girl of Cape Town
Who usually fucked with a clown.
He taught her the trick
Of sucking his prick,
And when it went up -- she went down.

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>

Apr 4 '06 #2
Its here because iam more concerned with c switch statements...I just
want to understand the term functional maps matrices...

Apr 4 '06 #3
sa*****@yahoo.co.in opined:
Its here because iam more concerned with c switch statements...I just
want to understand the term functional maps matrices...


Read the link in my sig before posting again, and quote context.

C language knows not of "functional map matrices" so posting here will
certainly not help you understand them.

As for the C `switch` statements, if you have a specific question about
them, do ask it here. Being "concerned" about them does not constitute
a question, though.

--
Binary, adj.:
Possessing the ability to have friends of both sexes.

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>

Apr 4 '06 #4
sa*****@yahoo.co.in a écrit :
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.


Maybe the meaning is the following:

Any switch statement can be replaced with a table (matrix) of
two columns:

In the first column we have the keys, or values in the "case" statement,
in the second we have the code associated with the key. If we would do
that in standard C we would have to define a function for each case
statement since we can't put labels in a table, at least in standard c.

This means that you replace the switch statement by a table lookup.

Since McCabe complexity measures the branching in a procedure, a switch
statement means (at least conceptually) a branch for each case
statement. In many compilers, more branches are generated internally in
the assembly code, but that is not considered by most implementations of
the complexity metric.

jacob
Apr 4 '06 #5
"Vladimir S. Oka" <no****@btopenworld.com> writes:
[snip]
--
There was a young girl of Cape Town
Who usually f***ed with a clown.

[snip]

You might want to consider tweaking your signature generator.
Four-letter words don't bother me very much, but some people are
likely to be offended.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 4 '06 #6

jacob navia wrote:
sa*****@yahoo.co.in a écrit :
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.


Maybe the meaning is the following:

Any switch statement can be replaced with a table (matrix) of
two columns:

In the first column we have the keys, or values in the "case" statement,
in the second we have the code associated with the key. If we would do
that in standard C we would have to define a function for each case
statement since we can't put labels in a table, at least in standard c.

This means that you replace the switch statement by a table lookup.

Since McCabe complexity measures the branching in a procedure, a switch
statement means (at least conceptually) a branch for each case
statement. In many compilers, more branches are generated internally in
the assembly code, but that is not considered by most implementations of
the complexity metric.

jacob


Since the McCabe metric is a measure of SOURCE CODE complexity, the
generated code is irrelevant. But often the switch() statement compiles
to a jump table so the number of branches can sometimes be less that
the equivalent count of cases.
Ed

Apr 4 '06 #7
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.
Apr 4 '06 #8
Keith Thompson opined:
"Vladimir S. Oka" <no****@btopenworld.com> writes:
[snip]
--
There was a young girl of Cape Town
Who usually f***ed with a clown.

[snip]

You might want to consider tweaking your signature generator.
Four-letter words don't bother me very much, but some people are
likely to be offended.


Ooops! Apologies to anyone offended. I tought I told it not to do that.
I'll go double check now. Sorry again, it wasn't intended.

--
Another dream that failed. There's nothing sadder.
-- Kirk, "This side of Paradise", stardate 3417.3

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>

Apr 5 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: threeseas | last post by:
Because the project is done in python and in support of FOSS http://msdn.microsoft.com/architecture/overview/softwarefactories/default.aspx?pull=/library/en-us/dnmaj/html/aj3softfac.asp ...
23
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
4
by: Generic Usenet Account | last post by:
Consider two entities A and B such that there is a 1:n association between them. I mean that associated with each instance of A there are up to n instances of B. Currently in our software we are...
8
by: Paminu | last post by:
I am trying to split my program in different parts. I have a file called mainfile.c that contains the main() function, some global variables and a few other functions. I then have a file...
77
by: M.B | last post by:
Guys, Need some of your opinion on an oft beaten track We have an option of using "goto" in C language, but most testbooks (even K&R) advice against use of it. My personal experience was that...
6
by: ganesh.kundapur | last post by:
Hi all, I need to know the complexity of implementing iostreams natively such as dependency on underlying OS. Regards, Ganesh
4
by: raghu | last post by:
How to find the complexity of a C program? Can anyone explain it with an example... Thanks a lot.
26
by: Lionel B | last post by:
Hi, Anyone know if the Standard has anything to say about the time complexity of size() for std::set? I need to access a set's size (/not/ to know if it is empty!) heavily during an algorithm...
6
by: thorsten.schilling | last post by:
Hello everybody, the question is, what is the "golden way" or the best way, if I have a memberfunction in a class, which should return a new instance of an object. For example some class Foo...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.