From Com to com
-- Hou Jie
Abstract:
This document introduces 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
Over the past eight years, I have moved myself out of the windows field to study and study. I should
One of the lucky people, the PC software industry took off, step by step to seize technical improvements
. My one-vote engineers and friends, for the sake of employment, it's not enough to finish the project all day long.
Available, it is difficult to have a good experience, charge learning time. There was a friend who worked hard on the overall technology.
Root error, I once said with emotion, if you can gradually learn, how good! Another reader wrote
Believe me: It's amazing to immerse yourself in books.
Unfortunately, the world does not wait for us. We had to adopt the "island jumping strategy 」.
During so many years of technical research, I felt like I was playing a jigsaw puzzle. Start with a program language and start with a job
The end of the system, including C, C ++, Java, SDK, MFC, VxD, Win32 OS, and multithreading.
, C ++ STL, Internet protocol .... I looked at this piece of puzzle and felt everything changed.
, Almost in my hands. No matter what newly developed object-oriented language,
Application Framework, new driver model, new protocol, I
I think that because I have mastered the basic knowledge, I was able to bypass the class. Another
In the operating system, I think that for processes, threads, modules, address space,
Executable File Format makes it easy for me to operate. Yes, I feel
An unprecedented level of stability.
Then I checked my technical blueprint and found that there was still a blank. It's actually a nightmare for years.
Something called Ole. It has grown like a big tree since its launch. It does not
However, the underlying architecture of COM is separated, and more features are added to the Internet, which is converted to AC.
Tivex.
In the past, I also made a lot of effort on OLE, and even got something that seems to be good so far.
Results. I often look at the OLE books I have read before, and I see my experiences and use
The exquisite experiences made by word and PowerPoint, as well as some completed manuscripts, were surprised to find
I have already worked on that level. However, after a moment of intoxicating
With a small voice, I asked myself: why have I forgotten all of them now?
● Know how and know why
Just like calcium supplementation, the important thing is not how much it absorbs, but how much it leaves. I forgot once again and again
I have mastered the COM/OLE technology because I have not laid a solid foundation for relevant knowledge.
. I may have learned a lot about how, but I don't know why. I have no idea about the principle.
Keep the maintenance I have absorbed.
This is contrary to my research spirit. However, for a long time, I have not found any ideal document.
Clarify the basic principles of OLE (actually com. I don't even know if that's true.
. In fact, I only need the one with the root cause. I can understand the root cause.
Make your own efforts.
By accident, I collected two books to finally integrate the subconscious for searching without knowing myself.
Things.
By accident, why is it not because of the accumulation of peripheral knowledge?
● Two good books
The two books I mentioned are inside the C ++ object model and essential com. Note:
They are all talking about object model, one for C ++ and one for components (software components
).
In earlier years, I had a great deal of interest in the layout of C ++ objects in memory and sorted out virtual machines.
Some experiences in underlying construction (I didn't know this field of knowledge was called C ++ Object Mode
L ). So when I looked at the pages of the inside C ++ object model, I intuitively told me that
It is a book I always wanted. In fact, it has been published for two years!
At the same time I got my previous book, I also got the latest published Essential COM. Introduction to the first two chapters of this book
Shao com's "why" is exactly what I need. I feel like I want to discuss why COM is needed.
Many of the technical backgrounds are covered by the C ++ object model. Besides, Essent
Don box, the author of ial COM, also strongly recommends inside the C to readers on the 16th page of the book.
++ Object model. Isn't that a reason? My own mining and Don box recommendations,
Happiness is difficult to describe.
This time, let me lay a line for you from the C ++ object model to the component object mod
El's Boulevard.
● Flashback
I'm afraid I have to use flashback to make it clear (and agree). Why is learning like "and Cheng"
Com, but requires a very deep structure of the C ++ language (for the compiler ).
Level.
Seriously think about this problem: there are both mfc1_dll, mfc40.dll, and mfc41.dl in my hard drive.
L, mfc42.dll, mfc50.dll... why? I am too lazy to sort out the updated version.
Hard Disk. Now I have thought of it. But do I dare to cut them down and keep the latest version? Me
No, because I'm not sure which version of DLLs is used for my application software. I would rather spend more disk
Space to store all historical traces-hard disks are cheap!
One way to avoid this is to avoid using DLLs instead of static connections (stat
IC linking) Forget it! This is the best illustration of "waste of food. With this idea, I will go into history.
Reactionary. You need to know that DLLs is a reusable module and does not have
. Otherwise, if the DLL is updated, it does not need to be re-linked with the client (
If the interface is not modified ). If you do not use DLLs, every application software will become a super fat man. This is
One of the problems. If you do not use DLLs, the development process of the application software will be severely hindered and the execution will be severely wasted.
Resources (especially memory), which is the second problem.
Therefore, software engineers decided to continue using DLLs. Assume that I decided to repair a batch of DLL 1.0 after one year.
Modify a class and add a private data to it. When DLL 2 is the same as 1.0
. 0 is installed on the user's hard drive, and the old dll version is overwritten. For new applications (DLL 2.0
Of course, this is okay. But when the applications that originally called DLL 1.0 are executed
, The system may fail!
Why? C ++ does not support data encapsulation? Isn't the newly added DLL private? Client
It is never possible to directly access that document! Although it is good, C ++ always relies only on private and PR.
Otected provides semantic encapsulation and does not provide binary level
. The C ++ compiler must have a full grasp of the object layout (on binary)
To create an object. The new private data added in the above example changes the object.
The memory layout of the object. The old client calls the new DLL!
The solution is to use different DLL file names to represent different versions, such as microsof.
T does the same for its Visual C ++ and Visual Basic. This is a saw arrow method.
But it does not solve the problem.
● Binary level
To solve this problem, you must change the DLL end without causing the client end.
Any changes. In real encapsulation, we must combine "what does an object look like" and "How does it actually work ?"
. This principle lies in the general binary level of C ++ object (bineary Leve
L) cannot be implemented (why? For example, C ++ object model applies ). However, for example
If we convert the original C ++ class into an interface class and an implementat
Ion class combination. Implementation class appears in the form of DLL,
While interface class becomes a basic category of implementation class, there is no
Data members is available only for implementation class methods
Letter declaration. You guessed it. All these announcements were designed as pure virtual letters. The pure virtual function is not
The only practice is the best practice.
Interface Class is responsible for connecting with the client to form the client and object DLL (implemen
Tation class) between a fire lane, complete the so-called binary encapsulation!
In addition to software version conflicts, another issue remains to be resolved. From various C ++ vendors to mangling
(Modification of the function name). There is no standard. The classes created in C ++ platform
DLL, which cannot be used in C ++ platform B. The interface and implementation
The separation method can solve the problem of incompatibility between the so-called compiler. In addition, for runtime polymor
Phism is also helpful for object extensibility.
● So-called Components
Objects, which is protected by a binary fire lane and saves the trouble of name mangling, is called
Components. It is not limited to which c ++ compiler is used for development, or even to which
Language. In fact, the component object model is a specification, but this specification is the most
It is close to the implementation method of the C ++ virtual function. The same type also has the System Object Model (
Som) and Common Object Request Broker Architecture (CORBA ).
As you can see, to learn about com, you only need to first understand why COM is needed 」. To learn more
Com is required. you must first understand why C ++ (or any current language) cannot do anything 」. While
To understand why "C ++ cannot do anything", you must understand what the "C ++ Object Model" is.
■ Inside the C ++ Object Model
Author: Stanley B. Lippman
Publishing Company: Addison Wesley
Publication date: 1996 pages: Chapter 7, 280 pages
Price: there is no price marked in the book (this book has no disk)
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 the book stack of C ++, this book is neither baby milk nor big baby milk powder,
It is a low-fat, high-calcium special milk powder for adults.
I have added some questions about C ++ objects in the C ++ or MFC courses
Materials of the long image and column layout in the memory, as well as virtual Implementation Technology and things inherited by category
Content, hidden this indicators... and other topics are very popular. None of these reactions left me alone
Expectation: engineers are eager to know the underlying things.
Many people wondered why I knew the underlying knowledge (some people thought I had microsof in earlier years
T or any other company's back-door pipeline-my friend heard a lecturer at a technical seminar.
In public ). This knowledge is made from a variety of technical documents or a book or an article.
It is obtained by breaking down the simple content. One part is the result of an experiment by writing a small program.
The outline of the C ++ object model in a miscellaneous way is very superficial. 1997
This inside the C ++ object model was inadvertently discovered at the end of the year, so that we can fully understand our shortcomings.
Complete.
This small book is thin and narrow, which is much smaller than the size of the original book. Dry and thin
Thin, only 280 pages. The lazy cover design, coupled with slightly yellow paper, cannot attract me much.
Fun. However, the author gave me two more eyes on it (Lippman has c ++ primer, and Bjarn
The C ++ programming language of E stroustrup is the third edition ). This
A glimpse of it was a little bit of a feeling of "crazy about poetry and books. Later on the essential com
Don box recommends this book: "... consult Stan Lippman's most excellent INS
IDE the C ++ object model for a great discussion of both techniqies. "I
Agree with Don box. This book is indeed "Most excellect ".
This book is not only in appearance, but also in content. The so-called C ++ object model is chilling
As if it is related to OOA/ood. In his preface, Lippman said that the C ++ object model has two slices.
Entry point:
1. Direct support for object-oriented programming provided by languages
The direct support for object-oriented programming provided within
Language
2. underlying mechanisms used to implement the above-mentioned support
The underlying mechanic by which this support is implemented
This book is about the second entry point. If you are interested in the composition of objects and materials
The object and the data in Chapter 3 must satisfy you. Regardless of the type inheritance method, virtual and Si
Ngle or multiple. The data attributes are static, global, or local.
And the key is represented by an image. This part is not worthy of my recommendation if it is not represented by an image.
After all, it is too hard to figure out the layout of the data column from the text description. Although
It can be described as "ugly" from an aesthetic point of view, but it is clear enough to show the author's ideas.
I think that's enough.
For example, if you specify the default constructor, copy constructor, and VI
Rtual destructor and underlying operation of various types of functions such as global, virtual, and static
For more information, see Chapter 2 constructor, Chapter 4 function, and chapter 5 "construction,
Deconstruct and copy can satisfy you. Chapter 6 resumption of discussion and introduction to the new and delete operations
Operator. Chapter 7 major extensions of C ++: Template, exception, and runtime type ident
Ification (rtti ).
For each topic, Lippman covers the origin of design, version evolution, and standards and practices.
Practice, and propose the efficiency test results of different platforms for some topics. This book is basically
It is written in a more academic way. Therefore, it is very small in terms of data processing and data sorting.
Fine.
When it comes to academics, it should be synonymous with rigor. However, there are about 100 written mistakes in this book. I dare not mess up
Said Mr. Hou Junjie was translating the book. He made an incorrect description of the original text, which was very difficult. The
C ++ has obvious syntax errors, which are relatively harmless and have limited damage to the system.
The inconsistency of the description, or the inconsistency between the illustration of the object layout and the announcement of the program code, will seriously mislead readers.
. In this regard, although beef is everywhere in this book, the cooking level of some parts,
It is detrimental to Lippman's reputation as a master.
The thickness of 280 pages is like a dish of small dishes for the Han-Man dinner on eight hundred pages. However
It's not difficult for a trainer to swallow. This is not a book for beginners of C ++.
Hou Jie strongly recommends those who are under pressure, have no test pressure, and have academic research spirit.
■ Essential com
Author: Don box
Publishing Company: Addison Wesley
Publication date: 1998
Page number: Chapter 7, page 440
Price: US $34.95 (non-magnetic)
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
No one knows about COM/OLE/active as a software engineer who asks for help on the Microsoft platform.
X is important. No one wants to understand and become proficient in this technology. There are not no good books, such as I
Nside Ole (fraig brockschmidt/Microsoft Press/1995) is related to almost every
All works must be included in the classic of bibliography or reference. But this book is like a book, "There are many
The word "tianshu", Hou Jie also worked very hard on it.
The reason is that in the early days, we had a hard time learning COM/Ole because we didn't have enough knowledge about the object model.
I have read a lot of books and have some experience using C ++/OO in actual development work. I will learn more.
Xi com/Ole.
Another reason is that there were very few good books that made com clear. I cannot
If you do not have such a book, you may be alone. Search for Baidu from the crowd. Now it is here.
This is essential COM.
● Don box
The author Don box is famous in the field of COM/Ole. He is at Microsoft Systems
Journal (MSJ) hosts an ActiveX/com q & A column, which has long been an outstanding strength. Let
I will record two preface articles to give you praise for Don box. You're right. What's wrong with the preface?
The author, happy family, but you can still feel the hype and sincere recommendations between words
Differences:
Article 1 Preface: Charlie Kindel Com Guy, Microsoft Corporation
If an English document talks about com, DCOM, Ole, or ActiveX, and I have read it, you almost
I will find my name listed in the Technical Review column as a credit guarantee. I wrote a lot myself
I am also the main editor of COM specification. I have given countless
Com briefing, whether for technical or non-technical personnel. Obviously, I spent a lot of time and effort
To find out the best description of COM.
When I read the last draft of this book, I understand that all my efforts are in vain. No permissions related to com
Who can explain it better than Don box!
Article 2 preface: Grady booch
If there are too many good things in a book, it is worth mentioning twice. Why is this? Don has two original orders.
Because.
If you are building a system on Windows 95 or NT, you cannot stay away from Com. If you
Want to (1) understand what is happening under the table (2) use the power of COM, Don is a perfect book
You.
One thing I like especially about this book is that Don describes how to organize COM. If you read this book
You do not know anything about com. You will be guided by a clear and simple com concept mode, so that you can understand the problem.
And the reason why com obtains its structure and behavior. If you are an experienced com
Developers, then you will be particularly appreciated when Don uses com to solve some common problems.
.
Note: The writer in the second article is Grady booch, a world-renowned master of object orientation.
● Why COM is required
The full name of COM is the component object model, which is used by Microsoft to solve software version conflicts and cross-Object
An object model designed and promoted for platform conflicts. It is a specification, while C ++'s
Abstract classes are the most similar to virtual functions.
I believe that at the beginning of learning how to use the COM/OLE technology, everyone has the same question: Why?
Com? Yes. Speaking of object-oriented technology, C ++ does not provide object encapsulation, inheritance, and multi-type features.
? Why does com?
The first chapter of this book helps you understand the design motivations of COM, including interface, reference count,
Createobject .... As long as you are familiar with the c ++ language, there is no difficulty in reading this chapter in form. For example
If you have the foundation of the C ++ object model, the first chapter gives you the feeling of being too powerful.
The second chapter introduces com interfaces. In the previous chapter, the author developed a virtual
The base class changes to the equivalent com iunknown interface. This chapter introduces
It introduces IDL (an Interface Description Language), midl (a Microsoft IDL compiler), guid
(A 128-bit number that does not repeat for years) and hresult (a common
Return Value Type), iunknown (the basis of all com interfaces ). Since many com progra
Mmer cannot call the addref and release of iunknown exactly. Don box
The top ten rules for young people are specially organized, and an example is provided to tell readers when to apply to which rule
. Very caring!
At the beginning of chapter 3, the book goes deep. At this time, I suggest you jump to another book: Inside
Com, and then go back to the next chapter.
The words in this book are more academic (I mean difficult ). This will enable unaccustomed readers to initiate attacks.
. Pay special attention to the first two chapters. They are the key to learning COM. These two chapters are systematic
In a step-by-step manner. Unfortunately, this book does not include code at all levels in stages (from
Abstract The design of the basic class, followed by the separation of interface and implementation, DLL
Add, reference counting design, QueryInterface design ...). I strongly
It is recommended that you have the desire and spirit of practice, and follow the instructions in the book to access COM step by step. Here you are
It may take some effort, because the book does not give you all the information (such as the design of the console DLL ..,
Basically, that is your necessary Foundation ). Maybe you will be stuck in a small level and cannot get back
. But in any case, you must try to achieve the most practical gains. This is my real evidence.
The Code related to this book can be obtained from the Don box website, but it does not contain the com
Implementation code for each development stage of the backbone program.
■ Inside com
By Dale Rogerson
Publishing Company: Microsoft Press
Publication date: 1996
Page number: Chapter 12, page 376
Price: USD 34.99 (including one CD)
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
10. servers in exes
11. Dispatch interfaces and automation
12. Multiple Threads
13. putting it all together
This book is simple, accurate, and fast. Each stage is accompanied by a complete program.
It is a pity that the starting point is not good enough. It is not analyzed from the origin of com just like the essential COM. Case 1
The foundation at the beginning was not well established, and the basic spirit of the entire com was still shaken, and the speed of the subsequent advances began to fear.
If you are afraid, you will not be able to hit the fifth grade.
My experience is that when I finish reading the first two chapters of essential COM and go forward in Chapter 3
Knee trembling, tongue bitter, back to look at this inside COM, One Night brush read 13
0 pages (the first six chapters), and have a good grasp.
The meaning of each sentence in each chapter in this book is quite good.
Clear (not a long string of clause concatenation words), so that we can read it all the way smoothly without having
In its article architecture, we can use the spirit of full payment to deal with COM technology.
Take inside COM and essential com together for the most benefit.
■ Understanding ActiveX and Ole -- A Guide for developers & managers
Author: David Chappell
Publishing Company: Microsoft Press
Publication date: 1996
Page number: Chapter 11, page 328
Price: US $22.95 (No discs)
1. introducting ActiveX and Ole
2. The Component Object Model
3. financialing and type information
4. Automation
5. Persistence
6. monikers
7. uniform data transfer and connectable objects
8. Ole compound documents
9. ActiveX Controls
10. Distributed COM
11. ActiveX, the Internet, and the World Wide Web
This book tells us that it is a book that can be viewed by managers. As a manager
However, there won't be too much code in the book. On the contrary, there are many text descriptions of abstract concepts.
I never believe that "abstract text instructions" can be understood by people who do not have the technical foundation of concrete. Me
Dare to talk about it. Yes, the above sentence applies to 99.99999% of Industrial people. So this book
In fact, it is only suitable for engineers trained by COM, Ole, and ActiveX. You can understand it now.
It.
People who can understand the book can't understand it, and no one can understand it. Isn't this book useless at all? No,
Its contents are well organized and attached with some well-designed diagrams, which can make our ideas clearer and even clearer.
To correct some of our possible blind spots that are vague and plausible. Carefully mark the white space on the Book Side
The focus of the paragraph text is a bit of the taste of the leader. Two-color printing is pleasing to the eye.