Re: Announcing Xrtti - Extended Runtime Type Information for C++
On May 1, 5:57 pm, bji-gg...@ischo.com wrote:
I haven't tested this code, I just wrote it out quickly, and there are
probably bugs and typos. But it illustrates the general technique you
would use to do this. The hardest part by far is having an algorithm
to "make up" test method arguments. I would expect that this would be
something you'd have to supply some kind of configuration file for.
I dislike being the one to discount other people work, since I
generally like creativity. However, I am going to play devil's
advocate here, as I am dislike more the principle behind this
example. Let me say first, however, that your motivation for the
framework, assisting with serialization of polymorphic object, I
believe is good. If the strings generated for the type_info in RTTI
were universal across compilers, then that would have greatly
facilitated serialization of polymorphic objects, as some type of
association between type name and regeneration function at the target
of the serialization would be possible. But back to the example that
you used - automated testing of classes. I am extremely wary of this
type of engineering/quality assurance. Think about the implication of
what you alluded to:
1. The code might be bad
2. You add code to the might-be-bad-code so that you can...
3. Write new code to check that the might-be-bad code is not bad.
Who is to say that the code that checks the might-be-bad code is not
bad itself. This technique is related to a mode of thought I
absolutely detest in software "engineering". It's a style of
programming where the code itself becomes the focus of the engineering
effort. Engineers sit around discussing the merits of one technique
over the other. Tools get written to test the code. Tools get
written to test the tools. And so on. Pretty soon you have
debuggers, profilers, optimizers, testers, etc....a hulking massive of
tools whose ostensible purpose is to yield a better product. This is
extremely inefficient. All of time, money, and effort spent on these
tools is probably better spend on dealing with #1 directly. Yes, a
good debugger is always necessary, but let's face it - when a product
is riddle with bugs, poor tools is *hardly* the problem. Microsoft
Visual Studio 2005, for example, is state-of-the-art. If there is
such a thing as professional-grade, each time you open up this IDE,
you're looking at it. It perplexes me that some people feel the need
to use not only this, but 4 other fancy tools. What about the
original problem? All these tools are nice, but you about the
programmer? What can he control? He can control #1.
When I hear about reflection and things similar to it (I spent weeks
trying to get colleagues to see that XML was not going to save the
world), I get the feeling that some programmers think that if they
just have a nice, polite, wholesome conversation with their code, it
will start to think by itself. This will never happen - software is
not artificially intelligent. Reflection will tell you about the
class, but once that it is known, the programmer still must decide
what to do. This the key. The machine is deterministic. The
programmer, and not the code, determines. If the programmer spends too
much time deciding whether to go left or right, depending up the the
type of a class or the value of an argument, or whatever, then that
represents precisely that which C++ was meant to help us get away from
- procedural programming.
-Le Chaud Lapin-
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]