C/C++
Testing Complex C++ Systems
By Gigi Sayfan, January 29, 2013
Some systems are so complex that they require non-traditional approaches to thoroughly test large code bases.Related Reading
More Insights
White Papers
- The Burnout Breach: How employee burnout is emerging as the next frontier in cybersecurity
- Building Immunity: The 2021 Healthcare and Pharmaceutical Industry Cyber Threat Landscape Report
Reports
- The Foundation for Building Scalable Applications to Fuel Customer Satisfaction and Growth
- 2021 Data Breach Investigations Report (DBIR)
Webcasts
- Rethinking Asset Management to Improve Enterprise Security
- Making Deception a Part of Your Enterprise Defense Strategy
Currently we allow the following HTML tags in comments:
Single tags
These tags can be used alone and don't need an ending tag.
<br>
Defines a single line break
<hr>
Defines a horizontal line
Matching tags
These require an ending tag - e.g. <i>italic text</i>
<a>
Defines an anchor
<b>
Defines bold text
<big>
Defines big text
<blockquote>
Defines a long quotation
<caption>
Defines a table caption
<cite>
Defines a citation
<code>
Defines computer code text
<em>
Defines emphasized text
<fieldset>
Defines a border around elements in a form
<h1>
This is heading 1
<h2>
This is heading 2
<h3>
This is heading 3
<h4>
This is heading 4
<h5>
This is heading 5
<h6>
This is heading 6
<i>
Defines italic text
<p>
Defines a paragraph
<pre>
Defines preformatted text
<q>
Defines a short quotation
<samp>
Defines sample computer code text
<small>
Defines small text
<span>
Defines a section in a document
<s>
Defines strikethrough text
<strike>
Defines strikethrough text
<strong>
Defines strong text
<sub>
Defines subscripted text
<sup>
Defines superscripted text
<u>
Defines underlined text
Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.
To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy. | |
I wish the style of the article was more reader friendly somehow.
The sentence as below is a brain hammer.
"I created plugins that reused the logic inside the fixed algorithm nodes and then constructed experiments that used the same networks with the same algorithm types and connectivity except that on one network the nodes used were the concrete (old) sub-classes of the runtime engine, and on another network all the nodes were PluginNode hosting the same algorithmic code"
A quick web search indicates that strong vs weak typing is neither well defined nor objective.
> it's just a technical term with a well-defined and objective meaning
Now I'm interested where you got your "sources" from. Or did you just make this up?
> asked before speaking
And in order to "ask" I would "speak" I guess?
> what you *can* do with the language
That's not true. In this vague sense you can do anything with every language. C++ is commonly seen as a strongly typed language. There is no discussion about it.
A language is weakly or strongly typed depending on what you can do with the language, not what uses are considered bad. It has no pejorative connotation; it's just a technical term with a well-defined and objective meaning. C++ is weakly typed.
You should have asked before speaking. The weakness or strength of the type system of a programming language is a technical concept, without any pejorative connotation. It doesn't mean bad (nor good), and talks about what you *can* do with the language (not what you *should* do).
I agree with most of your points. The terminology has taken on a bit of a political aspect within the C++ community. There is no doubt that by using the modern features in C++ with discipline, type safety can be assured. The "weak" part (an unfortunate descriptor, perhaps mutable and fixed would have been more neutral terms) comes in large part, but not exclusively, from the legacy of C. In this article, the author is discussing testing legacy codebases, so in that context, the challenges faced by testers due to the use of weak typing features seems appropriate to me. Zenju is right in his implication that developers who use the features are doing the linguistic equivalent of swearing. But the author's discussion of this is certainly not an attack on the language. It's simply a reflection of the reality of legacy codebases.
C++ is not weakly typed by most people's definition of what weakly typed means: that all class instances would be stored in an "object" type at compile-time, like C#'s ArrayList elements. On the other hand, a strongly typed language, by most people's definition, would have the types written out explicitly in the code; you could then perform compile-time error checking. The analogous C# collection in my example would be List<int>. C++ has always been a strongly typed language.
I think there has been an (unfortunate) conflation in recent years of weakly typed typed systems and type systems which happen to not have excellent security guarantees. Programming terms, jargon, motivations, concerns, etc. don't revolve around a type system's security guarantees; it's usually not the most important thing. I think many of us know that this specific denigration of the C++ language is basically propaganda by people who are promoting other languages with big security features.
Zenju: I can't tell if you're trolling or not, but 1) C++ is weakly typed. Do you really need a link for this? 2) C++ does take a long time to build. The article provides a link to Walter Bright's explanation of why C++ compiles slowly. Bright has written three commercial C++ compilers.3) Fast tight code is precisely the reason most C++ developers I know use the language. And given my line of work, I speak to a lot of C++ developers.
I'm not quite sure what you're so upset about. The author's claims seem reasonable to me and not inconsistent with my experience.
I do not see where the author makes a distinction between the language and code. Quite contrary he mixes it all together producing a number of statements that are wrong in their generality:
"C++ is a statically typed language, but its type system is very weak."
"Build speed is slow"
"C++ arguably poses the most difficult challenges for testing"
"C++ programmers love twisting code"
"C++ programmers [...] justifiably focus more than anything on generating fast and tight code"
By making these dubious statements without any reasoning right at the beginning of the article the author loses credibility and the reader interest to go on.
I'll support Zenju's comment. Saying C++ is weakly typed - regardless of the context, i.e. legacy systems - because a developer misused reinterpret_cast is a very misleading statement. This is an abuse of the statement, not the fault of the language. The casting operators are there for a purpose and useful when appropriate. They were introduced to provide control over the casting of C specifically to keep C++ a strongly typed system.
Regardless of how large the system is it might behoove the company to grep for reinterpret_casts and fix them.
Not sure I understand your comment or your recommendation. It's perfectly clear that the author is discussing code bases that already exist.
Of course, you are right about C++. But the author is pointing out some of the common problems you run up against when prepping tests on large, complicated systems -- and naughty usage is certainly common enough.
> type system is very weak. You can freely cast any pointer to any other pointer using reinterpret_cast.
"the english language is bad - you can swear a lot in it!". The author doesn't seem to be able to distinguish between what you can and what you should do. It's the common fallacy of confusing the code of some bad C++ programmers with the C++ language in general. I would suggest he read some new books on how C++ is used today, especially C++11.