Summary:
This article is a brief introduction to the basic concepts of C + + object model and Component object model and introduces four books:
1. Inside the C + + Object Model
2. Essential COM
3. Inside COM
4. Understanding ActiveX and OLE--A Guide for Developers & Managers
For nearly 8 years, I've banished myself to the Windows domain, learning and studying. I should be a fortunate group of people, in the era of PC software industry, a step-by-step grasp of technology to lift up. My vote. Engineering friends, because of the reason for the career, all day but the completion of the project is not yet available, in fact, it is difficult to have a good sinking starch experience, charge the time light. One of my friends was bitter about the whole technique of the plate, and I had the feeling that if we could learn it gradually, how good it would be! And one of the readers wrote to me and said, "It's so graceful to immerse yourself in the books."
Unfortunately, the world does not wait for us. We also had to take the "island hopping strategy".
In all these years of technical research, I felt like I was playing jigsaw puzzles. Beginning with a programming language, the system eventually includes C, C + +, Java, SDK, MFC, VxD, Win32 OS, multithreading, C + + STL, Internet Protocol .... I looked at this puzzle and felt that all the changes in the world were almost in my hands. No matter what new things are being exhibited to the language, what application the framework, or what the new driver model, the new protocol, I feel that because I have mastered the basic knowledge, I have been able to touch the bypass and have three opposite corners. Even for an operating system, I felt that my knowledge of processes, threads, modules, address space, and executable file format allowed me to easily and easily. Yes, I feel an unprecedented degree of stability.
and then I was reviewing my technical blue, and there was a blank space that didn't fill in. It's actually a dream of many years nightmare called OLE. That thing has grown from its present to today, and has grown like a big tree. It not only divides the structure of the COM hierarchy, but also in the Internet, adding more special qualities, to become ActiveX.
I've been doing a lot of work on OLE, and I've even got some of the results I still see today. I used to check out the OLE books I had read before, and I saw the dense head notes and the fine ideas that I made with Word and Powerpoint, and some of the books I had already completed, and I was amazed to discover that I had already been to the same degree. But it is always after a moment of intoxication that a little voice in your heart asks yourself: Why are you forgetting all this now?
Know how and Know why
just like bone calcium, . I have repeatedly forgotten the com/ole technique that I have mastered, because I am afraid that I have not put down put down to actually lay a foundation for knowledge. I probably learned a lot about how, but I don't know why. The understanding of the principle made me not be in a position to retain the nutrients I absorbed.
This contradicts the spirit of my research. But looking for foraging foraging for a long time, I did not find the ideal text to be able to explain the basic principles of OLE (which should actually be COM). I don't even know if I really have that kind of article or book. In fact, I only need the most root of the part. To realize the most fundamental part, I have the ability to degree of self-realization.
In a very casual situation, I Minatomachi River two books before finally integrating the things that the subconscious foraging foraging without realizing.
It is a coincidence that what is not the day of the moon's weary knowledge of the edge of the foot?
Two good books.
The two books I said are Inside the C + + Object Model and Essential COM. Notice that they are talking about the object model, a PIN to C + +, a pin to components.
In the early years I had a great interest in the objects of C + + in memory, as well as some of the experiences of virtual machine-based design (I didn't know that this knowledge domain was called C + + Object model). So when I looked at Inside the C + + Object Model, I was told that this was the book I had always wanted to have. In fact, it has been published two years, I really know later!
The same time I got the last book, I also got the latest published essential COM. The first two chapters of this book are about COM's "Why", which is what I desperately need. I feel that "there is much more to the technical context needed to com" this topic than the scope of the C + + Object Model. " and Don box, the author of Essential COM, is also in the 16th page of the book to recommend Inside the C + + Object Model. Isn't it because it's full of edges? My own development and the Don Box's recommended, two-matched and, fast-to-describe.
This time, let me open a path from the C + + object model to the Component Object model.
Inverted
I'm afraid I'll have to use the inverted way to make you understand (and recognize) why learning to "COM without programming" needs to be based on a very deep structure of C + + (which is the language of the translator) first. "
Really think about this question: MFC20.DLL and MFC40 exist in my hard disk. DLL, MFC41. DLL, MFC42. DLL, MFC50. DLL ..., why is this? Because of the version update, I lazy to tidy the hard disk. Now I think about it, see, but I dare to cut them off, just keep the latest version? I don't dare, because I'm not sure which version of my software to use DLLs. I'm willing to spend a little bit of disk space to place all the history--the hard drives are cheap anyway!
One way to avoid this is for the DLLs to use the static linking to stop the software from being used. This is the best picture of "choking on food". With this kind of mind, I went into the history of the anti-motion. To be aware, DLLs is a reusable module that does not have to be re-encoded because of changes to the client (caller). In the opposite direction, DLLs do not have to be re-contacted with the client if they are updated (if the interface is not changed). Without the use of DLLs, every application software becomes super fat, which is one of the problems. Without the use of DLLs, the process of software development suffers significant obstacles, and it is the second of the problem to execute heavy-weight resources (especially memory).
So the software engineers decided to continue using DLLs. Pretend I'm out of the factory a batch of DLL 1.0, a year later decided to modify one of the class, to add a private data. When DLL 2.0 with 1.0 is installed on the user's hard drive, the old version of the DLL is overwritten. For the new application (the caller of DLL 2.0), this is no problem. But when the application that originally called DLL 1.0 was executed, the system might be out!
Why? C + + is not a support for the packaging of materials? The new DLL information is not private? The client will never be able to access that information directly! It is not bad, but C + + only relies on the private and protected two reserved words to provide the language of the packaging, and did not provide two level (binary) packaging. C + + translator must have a complete grasp of the physical layout of the object (two in the mastery of the master), only to create a physical object; The above example adds a new piece of private information to change the object's memory layout, the old client calls the new DLL, hehe, not when it is the weather!
The solution is to "use different DLL files to represent different versions", as Microsoft has done for its Visual C + +, visual Basic. This is a saw arrow method that avoids the problem, but does not solve the problem.
Binary level
to really solve this problem, you have to make any changes at this end of the DLL without causing any changes to the client side. The real thing is to separate the "object from what it looks like" and "how the object Works". This principle is not implemented in the general C + + object two level (Bineary) (why?). This is the categories of C + + Object Model). But if we change the original C + + class to a combination of a interface class and a implementation class, we can do that. Implementation class is presented as a DLL, and interface class is a basic class of implementation classes, with no information (data members), only the Implement Ation class methods declaration of each function. You guessed it, these declarations are designed to be pure virtual functions. Pure virtual functions are not the only approach, but they are best practices.
Interface class responsibility and client union, forming a fire lane between the client and the object DLL (Implementation Class), completing the so-called two-pack!
In addition to software version conflicts, another problem remains to be resolved. Due to the different practices of the C + + vendors for mangling (function name modification), there is no standard, the classes DLL made in C + + platform A is not guaranteed to be used in C + + platform B. The above-mentioned practice of interface and implementation can solve the problem that the translator is incompatible. It also helps with the runtime polymorphism, and also helps with object extensibility.
What are the components
Protected by two advanced fire lanes, and exempt from the name mangling objects, is called the components. It is not self-limiting to what kind of C + + translator to use, and it is not limited to which programming language to use. In fact, the Component Object Model is a specification, but the actual way that this specification is most closely attached to C + + virtual functions is strikes. The same type of specification also has the System object Model (SOM) and the Common object Request Broker Architecture (CORBA).
I think you've seen that to understand COM, you have to understand why you need com". To understand why there is a need for com", it is necessary to understand"c++ (or any of the current languages) for what is not. To understand why "c++ cannot do so, it is necessary to understand the"c++ object model.
Inside the C + + Object Model
Stanley B. Lippman
Publishing Company: Addison Wesley
Publication date: 1996 pages: 7 chapters, 280 pages
Price: There is no price on the book (This is not a magnetic film)
1. Object Lessons
2. The semantics of constructors
3. The semantics of Data
4. The semantics of Function
5. Semantics of construction, destruction, and Copy
6. Runtime semantics
7. on the Cusp of the Object Model
In C + + Chengshan like the Sea of books, this is not a baby infant milk powder, is not a larger infant milk powder, it is used for adult low-fat high calcium special milk powder.
I have been in several C + + courses or MFC classes to supplement some of the information about C + + objects in memory with the linked fields, as well as the actual technology of the virtual function, the contents of the object of the class, and the hidden this indicator ... and so on. And so on, it was a great welcome. These reactions are not out of my expectation: engineers are eager to know what's on the bottom.
A lot of people wonder why I know these layers of knowledge (some people in the early years think I have a back-pipe for Microsoft or some other company--this is what my friends hear from the lecturer in a technical research session). A part of this knowledge is from a variety of technical documents or a book or an article to get the text, part of the fact that they actually write a small program to do the experiment.
I've made the shallow of the C + + object model in a very complicated way, and it's still rough. The inside the C + + Object Model was not discovered by the end of 1997, which completely praya its flaws.
This little-looking book, thin and narrow, is much smaller than the size of the general text. Dry and thin, only 280 pages. The "vulgar Canary" cover design plus the micro-yellow paper, originally could not afford me much interest. But the author's name made me look at it in more than two eyes (LippmanC + + Primer, with Bjarne Stroustrup'sThe C + + programming Languageis now the third edition). It's a bit of a "comic book-Crazy" sensation. Later, on Essential COM, I saw Don Box recommend this book: "... Consult Stan Lippman ' s Most excellent Inside the C + + Object Model for a great discussion of both techniqies"I agree with Don Box that this book is" most Excellect ".
This book returned to rustic true, not only the appearance of this, the content is also so. The so-called C + + object model, Wen's very bold, seems to be and what ooa/ood. Lippman in its preface that the C + + object model has two points of entry:
1. Direct support to programming for objects provided by language
The direct support for object-oriented programming provided within the language
2. A bottom-layer system for the actual support given above
The underlying mechanisms by which this support is implemented
This book is talking about the second cut. If you have a strong interest in the composition of objects and materials, the first chapter of the object and chapter III Data must be sufficient to satisfy you. Regardless of whether the type of inheritance is virtual, single, or multiple, the material is static, global, or local, and these two chapters are discussed and expressed in the key. This part if not to the picture, it is not worth my recommend, after all, from the text of the structure to come up with information linked fields, the Commission is too hard. Although it is possible to describe the author's ideas from the point of view of the ugly, it is sufficient to be able to function.
If you are interested in a few basic membership functions such as default constructor, copy constructor, virtual destructor, and the bottom layer of each type of function such as global, virtual, and Static, The second chapter of the Constructor, the fourth chapter of the Function, as well as the fifth chapter of the "Construction, Jie and copy" is absolutely enough to satisfy you. The sixth chapter continues to talk about functions and talks about new and delete two operators. The seventh chapter discusses the three major expansion of C + +: template, Exception, runtime type identification (RTTI).
For each topic, Lippman covers both the design, version, and Standard, as well as the performance of the different platforms (platform) for some subjects to test the results. This book is basically written in a more scientific way, so it's very detailed in terms of the numbers and the collation of the information.
When it comes to learning, it should be the nominee word of strict Kan. But there are about 100 mistakes in this book. I dare not to say that Mr. Hou Jun is translating this book, and he made a list of the original, dense. The C + + apparent language is wrong, is not very hurt, and the damage is limited, however, such as the name of the code symbol is inconsistent with the text, or the object layout of the map and the Code of the Declaration inconsistent, will seriously misunderstand the reader's mental effort. In this view, in fact, this book, although there are all the beef, but some parts of the cooking standard, in fact, the Lippman of the teacher reputation.
The thickness of 280 pages, craftsmanship 800 pages of the present-day feast to say, like a dish. But back spicy belt unmotivated son, not practicing swallowing. This is not a C + + beginner's book, and Houtie is recommended for those who have no pressure, no test, and a spirit of healing.
Essential COM
Don Box
Publishing Company: Addison Wesley
Published Date: 1998
Pages: 7 Chapters, 440 pages
Price: US $34.95 (no magnetic film)
1. COM as a Better C + +
2. Interfaces
3. Classes
4. Objects
5. Apartments
6. Applications
7. Miscellanea
A. The Evolution of Objects
B. Selected Code fragements
All software engineers who live on the Microsoft platform do not know the importance of Com/ole/activex, and no one wants to understand and practice this technology. There is no good book, for example, Inside OLE (Fraig brockschmidt/microsoft press/1995) is almost every work to be included in bibliography or Reference classics. But the book is very much like a "many words of the books", Houtie also climbed very hard.
The reason for this is that in the early stages of the Object Model, it was difficult to learn com/ole. Slowly we read more, in the actual development of the work with C++/oo, there are some experience, and then to learn com/ole, more than can gradually into the nirvana.
Another reason is that it is very rare to have a good book that can tell the story of COM to the dragon. I cannot say that there is no such book, maybe it is a lonely leak. The audience is looking for it 1100 degrees, now it comes, is this Essential COM.
About Don Box
The author Don Box is a famous com/ole in this field. He presided over a activex/com MSJ at Microsoft Systems Journal, who has long shown remarkable strength. Let me show you the two preamble to Don Box's praise. You're right, the preface is not flattering the author, Happy family, but in the words of the word you can still feel the big difference between the agnostic and the recommended:
First preface: Charlie Kindel COM guy, Microsoft Corporation
If you have an English book that talks about COM, DCOM, OLE, or ActiveX, and I've read it, you'll almost certainly find my name listed in the technical linked fields as a credit certificate. I also wrote many of these technical articles myself, and I was also the main editor of COM specification. I gave an infinite COM brief, whether it was a technical or non-technical person. Obviously, I spent a lot of time and effort trying to figure out the best way to explain COM.
When I read the final draft of this book, I knew that all my efforts were wasted. With COM, no one can makes better than Don Box!
The second preface: Grady Booch
A book of good things if too much, it is worth saying twice. That's why Don has two sequential books.
If you're building a system on Windows 95 or NT, you can't be away from COM's categories. If you want to (1) understand what's happening under the pool table (2) with the power of COM, Don's book suits you.
I'm particularly fond of this book, and Don is talking about the way COM is organized. If you are not aware of COM at the time of reading this book, you will be guided by a clear, simple COM-view pattern that allows you to understand where the problem lies and why COM is getting its structure and behavior. If you are an experienced COM publisher, then you will be particularly aware of the various perspectives that Don puts forward in solving some common problems with COM.
Note that the second preface is Grady Booch, a world-renowned object directed to the master character.
Why do I need COM
The full name of COM is the Component object Model, which is micro-software to understand the version of the software conflict, the object cross-platform conflict ... And so on, a model of the object that is designed and driven by the main problem. It is a specification, and the abstract type of C + + is most closely attached to the actual way the virtual function is written.
I believe that at the beginning of learning how to use com/ole technology, everyone's questions are the same: why have COM? Yes, to say that the object-oriented technology, C + + does not provide the object of the packaging, inheritance, multi-type characteristics? Why is COM?
The first chapter of this book gives you a clear idea of COM's design, including interface, reference count, CreateObject .... As long as the Hyo C + + language, in the form of looking at this chapter is not difficult. If you have the base of C + + Object Model, the first chapter can give you the feeling of Daigo filling.
The second chapter introduces COM interfaces. In the previous chapter, the author evolved a virtual base class which became a function-to-wait COM IUnknown interface. This chapter introduces IDL (a interface Descriptive language), MIDL (a soft set of IDL translators), a GUID (a 128-bit number that is guaranteed to be non-repeating for billions of years), HRESULT (a return-valued form common to any platform), IUnknown (All COM Interfaces of the base). Because many COM programmer are not able to properly call IUnknown's AddRef and Release two functions, Don Box does a good job of sorting out the ten best practices of youth and provides an example of what the reader should be using. Very good!
The third chapter begins, the book goes to the direction of deep Shibuya. At this point, I suggest you jump first to read another book: Inside COM, and then go back to the next chapter.
This book is more technical (I mean grueling Shibuya). This causes the non-accustomed reader to be hindered in the attack. Read on to read the first two chapters, which are the keys to learning about COM. These two Zhangneven are systematically orbiting around an example and are progressively progressing. Unfortunately, this book does not have a hierarchical level of code (from the beginning of the abstract basis of the design, and then the separation of interface and implementation, DLL join, reference counting design, QueryInterface design ... )。 I strongly recommend that you have the desire and the spirit to be realistic, and follow the instructions in the book to get closer to COM in one step. You may eat a bit of pain in this, because the book does not give you all the information (such as the design of the console DLL, basically it is your necessary basis). Maybe you'll be stuck on a little card and you won't be allowed to. But in any way, you have to try to do it before you have the most realistic harvesting. This is my reality certificate.
This book's code can be obtained from the Don Box's web site, and does not contain the various development stages of the COM bone-stem program described above.
Inside COM
Dale Rogerson
Publishing Company: Microsoft Press
Published Date: 1996
Pages: 12 Chapters, 376 pages
Price: US $34.99 (with CD piece)
1. Components
2. The Interfaces
3. QueryInterface
4. Reference counting
5. Dynamic linking
6. HRESULTs, GUIDs, the Registry, and other Details
7. The Class Factory
8. Component Reuse:containment and Aggregation
9. Making It Easier
Ten. Servers in EXEs
Dispatch Interfaces and Automation
Multiple Threads
Putting It all Together
This book shallow clearly, the rationale is accurate, the advance speed is appropriate, each stage is accompanied by a complete program. Unfortunately, the head is not good enough, no like essential com from the beginning of the analysis of COM origin. All the foundation of the beginning is not good, the basic spirit of the whole COM still self-shaking, behind the speed of the push is probably no way to hit five.
My experience is that when I read the first two chapters of Essential COM, and in its third chapter creeping forward, grinding the knees micro-trembling, the tongue is bitter, back to the head to see this Inside com, a night brushing brush see 130 pages (the first six chapters), and the mastery is quite good.
In each chapter of this book, the first and last words of each section say that it continues to be very good, the language of each sentence is also very clear (does not use a long string of clauses connected to the word), let us all the way to read few laps pleasure, do not need to spend more time in its article structure, can pay the spirit to pay for COM technology.
Take Inside com and Essential com together to see, can get the most benefit.
Understanding ActiveX and OLE--A Guide for Developers & Managers
David Chappell
Publishing Company: Microsoft Press
Published Date: 1996
Pages: 11 Chapters, 328 pages
Price: US $22.95 (no disc)
1. introducting ActiveX and OLE
2. The Component Object Model
3. Marshaling and Type Information
4. Automation
5. Persistence
6. Monikers
7. Uniform Data Transfer and connectable Objects
8. OLE Compound Documents
9. ActiveX Controls
Ten. Distributed COM
One. ActiveX, the Internet, and the world Wide Web
The copy of this book clearly tells us that it is a book that can be read to the manager. Since it is written for the manager, there is not too much code in the book, but rather more abstract reading.
I have never believed that "abstract words" can be understood by people who do not have an "image technology base". I dare to say death, yes, the above sentence is suitable for 99.99999% of the industry people. So, this book is actually only suitable for the engineers trained by the Com/ole/activex to see. You have already, you can understand it.
Talent can understand, not people can not understand, then this book is not a bit of use there is no? No, its contents are well organized and attached to some well-designed maps to make our observations clearer and even correct some of the vague, plausible blind points we may have. The left side of the book is carefully labeled to show the heavy point of the paragraph text, a bit of the flavor of the word. Double color printing, it is a joy to admire.
---the end---
From COM to COM Houtie 1998.06.12