McCabe Complexity Calcuation and Polymorphism

"Quinn Tyler Jackson" <qjackson@wave.home.com>
13 Sep 1998 22:27:00 -0400

          From comp.compilers

Related articles
McCabe Complexity Calcuation and Polymorphism qjackson@wave.home.com (Quinn Tyler Jackson) (1998-09-13)
| List of all articles for this month |

From: "Quinn Tyler Jackson" <qjackson@wave.home.com>
Newsgroups: comp.compilers
Date: 13 Sep 1998 22:27:00 -0400
Organization: Compilers Central
Keywords: analysis, question

Hello:


I am currently working on a C++ source code reformatter as a personal
project, and I intend to include a facility displays the member
functions of a class sorted by their McCabe Complexity.


The MC is incremented by one for each decision point in a function, so
I've been wondering if it would make sense to also increment it by one
when a virtual member function is invoked. For instance:


        class Base
        {
                public:
                        virtual bool some_func(void);
        };


        class Child : public Base
        {
                public:
                        virtual bool some_func(void);
                        void some_other_func(int a);
        }


        void Child::some_other_func(int a)
        {
                if(a > 10)
                {
                        some_func();
                }
        }


I calculate the MC for some_other_func to be 2, but it would be 3 if I
were to take the virtualness of some_func into account. Does anyone
have any ideas on this? Pointers to papers?


Thanks in advance,


Quinn Tyler Jackson


email: qjackson@wave.home.com
url: http://www.qtj.net/~quinn/
ftp: qtj.net
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.