jacob navia wrote:
I was browsing the web pages of les haltton, a software engineering
professor ( http://www.leshaltton.org ) and I found this data in
htp://www.leshatton.org/Documents/dross_2006.pdf
< begin quote >
Summary of known measurements
· C++ OO systems have comparable defect densities to conventional C or
Pascal systems.
· Each defect in a C++ OO system takes about twice as long to fix as in
a conventional system.
This is true for both simple defects AND difficult ones. The whole
distribution is right shifted.
· Components using inheritance have been observed to have 6 times the
defect density.
How much of this is attributable to C++ is unknown.
< end quote >
It is obvious that beside the much touted hype, OO systems have
not brought any real improvement to C. The problem is in my
opinion, the staggering complexity of those systems, what
makes debugging thema nightmare unless you wrote them.
I'm the last person in the world to defend C++ over C, however, these
statements are missing some very important considerations.
1) You can accomplish *more* in C++ per line of code. Its not
drastically more, but its definately more. Constructors and
destructors are often called by default, you have exception handling
which means you don't have to write very convoluted clean up code for
successfully backing out of errors, and you have templates which means
algorithms can truly be reused over different types. So in essence
this analysis fails the typical "lines of code" fallacy.
2) The *severity* of defects for the two languages is also very
different. Many of the containers in STL remove the need to use
pointers and "by hand" memory management. So a lot of things like "use
after free", pointing to non-sense, uninitialized pointers, and
ordinary buffer overflows, will tend to be less frequent in C++. The
real problem is that C++ introduces a totally new programming paradigm
which in of itself has built-in potential for errors that raw C doesn't
have. Thus this analysis treats all kinds of errors as if they are the
same as well.
3) C++ is not the only embodiment of OO. Other languages such as Java,
Ruby, Python and Lua have their own notion of OO programming. Its
obvious that in these languages, errors are less severe, the rate of
error production is code is far less, and the productivity per line of
code is also much higher. So I don't think that "OO" is, in
particular, either a culprit or an antagonist to reducing the number of
errors in a program.
--
Paul Hsieh
http://www.pobox.com/~qed/ http://bstring.sf.net/