The COM part is still not correct as I explained in my email to you, because it reflects the only way you should not ever never use COM.
I will do a follow up (as per email) this weekend. For starters: there are no memory leaks....
COM should be used through interface instances, not class instances as in your book. And you should respect the reference counting. TComponent is a really bad example...
As for memory leaks: In my example, there are no memory leaks, indeed. In the example you send me through email, there were memory leaks. Simply checking with "-gl -gh" shows this. You probably wanted to use there TInterfacedObject instead of TComponent.
As for the TComponent, with it's _AddRef implementation that disables reference-counting: it is not my invention. It's part of a standard Pascal library, and a basis for countless classes. Showing how TComponent interacts with COM interfaces seems justified.
I agree that, if you just
never use class instances to interact with things that are also accessed through COM interfaces (and always descend from TInterfacedObject, with proper _AddRef implementations), then you're safe. If you *want* the reference-counting of COM interfaces, then COM interfaces are a good deal. I'm open to improvements, my example and wording could probably be improved.
My current example is a way to show how to make something equivalent to previous CORBA example using COM -- it's referred to in the next section (about typecasting of interfaces too). It could be moved to a separate section ("Hacky usage of COM interfaces without reference-counting"), and the basic COM section could describe the "proper" COM usage.
"GOOD" and "UGLY" interfaces is really not serious in a technical writing. You're not the guy who decides that. Some people have to work with COM as a constraint, your opinion does not matter, they have to do it. dot.
I know that my opinion doesn't change the language -- that's why there is a description of both COM and CORBA interfaces in the article.
But, for some weird reason, I still do have some opinion:) The reasons why I feel that COM interfaces are "ugly" is clearly explained in the article.
I also know how interfaces look like in C# and Java. As it happens, C#, Java and CORBA interfaces are the same. The COM interfaces are different, and I heard a "WTF?" reaction when telling programmers that in Pascal we have interfaces entangled with reference-counting ("WTF -- these are two completely different language features, with different use-cases, should be orthogonal"). So it seems that I'm not alone in my opinion. And to explain interfaces to programmers coming from other languages, CORBA interfaces are more natural. (Regardless whether CORBA or COM are better.)
You could put a paragraph about class var, class properties, class constructor and class destructor.
Good idea! And thanks for good comments -- you're welcome to post about the article everywhere:)