* James Kanze:
[...]
How do you know? There was nothing in the original posting to
suggest it, and it's rather the exception, and not the rule.
On the contrary, from the original posting:
* (e-mail address removed):
Now somewhere, actually EVERYWHERE in this legacy code I see
statements like this;
// semi pseudo with
abstractTarget* createTarget(abstractDescription* desc)
{
// shortcut pseudo code for dynamic cast< > ()
if ( desc is concreteDesc1)
{
return new concreteTarget1();
}
else if (desc is concreteDesc2)
{
return new concreteTarget2();
}
else
{
return 0;
}
}
Notice that no information about the created objects is retained.
Hence, as I figure it, the caller has the responsibility for destroying
them.
In other words, since no information is given, you suppose the
exceptional case, rather than the usual.
No. First, there's lots of information in the example above. Second,
what's "usual" for you is, I suspect, rather different than the norm in
industry, especially for old legacy code; a better term might be
"ideal", that you're wondering why I'm assuming the code isn't ideal...
Can you really imagine the programmer who created the above, doing
registration for events in e.g. concreteTarget1's constructor?
I can't -- but then, if the OP states otherwise (which would be
inconsistent with comments else-thread), I'd have to revise my opinion.
Cheers, & hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?- Hide quoted text -
- Show quoted text -