Bill Sudbrink wrote:
Don wrote:
> And, in languages like C++, all of the machinery going
> on "behind the scenes" (automatic type conversion,
> constructor invocations, etc.) is so far out of the
> typical "programmer's" mind/scope of knowledge that
> it's a wonder *anything* works! :-(
That's exactly the kind of stuff I have to deal
with on a
regular basis. We have a large database manipulation application
full of classes with accessor methods that return instances of
string classes. Copy constructors executing all over the place.
Memory being uselessly copied from place to place accounts for
Exactly. "X = Y" can consume a sh*tload of cycles
depending on what X is, etc.
over 30 percent of the app's CPU usage.
Programmer's response
to the suggestion that maybe some of the accessors return
(const char *) insead?
"That's just wrong." "My classes are bullet proof."
"Someone
could recast the pointer and sabotage my classes." "Modern
computers have plenty of CPU capacity."
This code does not go out of our shop... We all regularly
review each other's code but he spouts all of the "patterns"
nonsense.
I suspect the code was never "engineered", either.
Just slapped together until it worked and then kept
that way as a "fait accompli".