J
Juha Nieminen
Consider the code example here:
http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.9
It needlessly allocates an object dynamically and, what's worse, it
never deletes it.
Let me emphasize that I understand perfectly that this is done to keep
the example short and simple, and that I understand that *how* the
object is created is completely irrelevant with respect to what the
example is trying to show. (In other words, the allocation of the object
is not the point of the example, but how the object is used in the
subsequent lines.)
However, given that, AFAIK, this FAQ tries to teach good programming
practices in C++, this is a horrible example of that. Even though this
has been done to keep the example simple, there's always the danger of a
beginner programmer seeing this and getting the impression that it's
normal and ok to allocate temporary objects like this and leave them
hanging. Even if allocating the object dynamically would be excusable
(for the sake of simplicity), not deleting it certainly isn't.
(Btw, I once contacted the author of the FAQ about this issue by
email. I clearly explained that I understood why it's done like that,
ie. to keep the example simple, but that I still think it's a bad idea
to teach bad habits to beginner programmers like this. His reply was
extremely disrespectful, arrogant and outright insulting. The example
code was naturally never fixed. I really couldn't understand that kind
of response.)
http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.9
It needlessly allocates an object dynamically and, what's worse, it
never deletes it.
Let me emphasize that I understand perfectly that this is done to keep
the example short and simple, and that I understand that *how* the
object is created is completely irrelevant with respect to what the
example is trying to show. (In other words, the allocation of the object
is not the point of the example, but how the object is used in the
subsequent lines.)
However, given that, AFAIK, this FAQ tries to teach good programming
practices in C++, this is a horrible example of that. Even though this
has been done to keep the example simple, there's always the danger of a
beginner programmer seeing this and getting the impression that it's
normal and ok to allocate temporary objects like this and leave them
hanging. Even if allocating the object dynamically would be excusable
(for the sake of simplicity), not deleting it certainly isn't.
(Btw, I once contacted the author of the FAQ about this issue by
email. I clearly explained that I understood why it's done like that,
ie. to keep the example simple, but that I still think it's a bad idea
to teach bad habits to beginner programmers like this. His reply was
extremely disrespectful, arrogant and outright insulting. The example
code was naturally never fixed. I really couldn't understand that kind
of response.)