> Is the MS COM CString implemented with all static functions? (a "C" string
> object? it's been too long since i used it).
>
> It doesn't matter. Not everything has to be a COM object (in the sense of
> "implement IUnknown"). As long as you declare it with the __declspec
> nonsense, it will be in the COM object format. The only time you need to
be
> an IUnknown is if you need rtti (which is overused anyhow, imho). So
utility
> objects should be fine.
>
> Obviously that makes any utility that doesn't declare its methods right
...
> buggy :)
>

There is no COM CString implementation. There is the MFC CString, but that
is just your typical Copy on Write string class.

COM has BSTR (B-Strings) but these are just counted arrays of unicode
characters and that is all. Just data, not function.

I don't understand what you mean about using __declspec, do you mean the
calling convention of the methods of an object (__stdcall, etc.). You can
only pass interfaces and base types cross interface, otherwise you might
come across some compiler incompatibilities. By using COM and IUnknown you
are basically only passing virtual tables for everything, which are compiler
independant (as long as you do not use multiple inheritance.) Another
problem is you can not delete an object which is created from another
compiler. How would you? You don't know how it's memory is managed or
anything. What's worse, the pointers or references to the classes you are
passing back and forth could have different declared implementations on both
sides of the interface. CString (as an example) on one side could have a
method GetLength( ), and not have it in the header definition on the other
side. So what happens if the side without creates a CString object, passes
it across the interface boundary, and the guy on that side tries to call
GetLength( ) on it?

Interfaces let you abstract the definition from the implementation. This is
very powerful. It prevents you from knowing or caring how it is implemented
on the "server-side" of the interface. This allows you to eliminate many
ugly dependency issues (versioning and what not) which can arise in any
large application.



Reply via email to