[Effective-cpp] Item 2: The String Formatters of Manor Farm, Part 1: sprintf

Balog Pal pasa at lib.hu
Sun Oct 31 13:52:29 EST 2004


> While this is all true, CString is absolutely MS specific, and therefore
no
> use for many programmers (including myself).

Can you explain that?  What exactly is MS specfic in it? How any programmer
is prevented from using it?  How it differs from any other string classes
written by NHL, Dave Nugent, Jerry Coffin, Scott Meyers or the several ones
I wrote.

> So while it is worth to
> mention that it exists for the Windows platform, I do not think it belongs
> to the same discussion where boost and the standard library is mentioned.
> First of all it may confuse people (who do not have it or have it and they
> do not know it is non-portable).

Is it non-portable?  I used it on at leas six different compilers, and
multiple platforms from unix versions to embedded stuff.

It is a library class, not a piece of black magic.   And certainly the same
thing applies to other libraries.

> Then in additoon I have read once a very
> nice article from a well-known name (which I am sorry I cannot recall)
about
> why CString is plain bad C++ design (along with most of MFC).

Most of MFC is indeed ranges from mediocre to extremely poor C++ design.
CString may have a single feature of debate -- an implicit conversion to
const char *.  What a group of teachers believes to be a Bad Thing (TM),
while most users seem to like it (myself included), and enconter non of the
predicted problems IRL.

OTOH there wore a plenty of discussions on misdesign of std::string, and all
its consequences from implementations broken in MT environment to forcing
NOT to use the very implementation model it was to support at designing
stage.

If whe designers jut took a look at CString's interface to learn why it goes
that way, the mentioned problems could have been avoided in the first place.

> Which may be
> convenient at times, but it is rather Java (Smalltalk) than C++.  All that
> said, std::string is a monster in itself, but that is a monster due to
> existing practice/lazyness (called compatibility by the politically
correct)
> rather than bad fundamentally wrong desing ideas (cosmic hierarchies
etc.).

Huh?   I can't figure out the point here.

> Or IOW again: I will not port MFC to Solaris or Linux (or buy its port
> either for that matter) to use CString.

Why should you?  CString works completely separate from anything else in
MFC, and no envronment is needed.  IIRC the only fuction I couldn't map was
Reverse, but as I never used it, I just dropped it. :)  But guess anyone
could implement it in 10 minutes if needed.





More information about the Effective-cpp mailing list