170 likes | 364 Views
Component-Based Software Engineering Component Technologies . COM Overview of COM. Overview of COM. What is COM History and Background Fundamental Concepts Software Components as Building Blocks The Component Object Model Defined Resources Existent COM Technologies Useful COM Tools
E N D
Component-Based Software EngineeringComponent Technologies COM Overview of COM Component technology
Overview of COM • What is COM • History and Background • Fundamental Concepts • Software Components as Building Blocks • The Component Object Model Defined • Resources • Existent COM Technologies • Useful COM Tools • C++ vs. COM • COM Advantages Component technology
What is COM • Component software model Component def. “…binary, self-contained, reusable, language neutral piece of software” • COM is a Microsoft solution • Based on • The OO paradigm • Binary reuse • Interfaces • Language independent • Clients bind to objects at runtime • Provides • Integrated services, easy-to-use tools, available applications • Market for reusable, off-the-shelf, client and server components Component technology
History & Background • Microsoft’s Component Object Model (COM) • The first component model. • 1988 - OO infrastructures that provides reuse based on components • OLE2 project • OLE - Object Linking & Embedding 4 high-level requirement for a new component architecture • Component-based • Based on the OO paradigm • Language independent • Interprocess communication Component technology
History & Background, cont. • OLE = COM • but COM was an essential piece of the OLE2 project • COM specification • Specific memory layout • One or more COM interfaces • Communication only through interfaces • 1995 DCOM • Allows creating and accessing COM objects on remote location • 1999 • Over 150 million systems worldwide Component technology
Fundamental Concepts • COM Interface • a collection of abstract operations one can perform on an object • COM Object • a collection of vptrs in memory that follow the COM identity laws • has methods and state • COM Class (or coclass) • is a named body of code that can be used to produce COM objects • Class object or Class factory • initializes the creation of an object. • SCM (Service Control Manager)or class loader • on demand, load all coclasses • COM library • infrastructure used to support COM on a given platform Component technology
A Simple COM Object • A COM object has methods and state • Language independent • All Access is through the interface • Supports multiple interfaces • Each interface has a GUID Component technology
IUnkown • All COM objects must implement IUnknown • AddRef • Release • QueryInterface IUnknown Component technology
4. Invoke methods 3. Return pointer to interface 2. Create Objectand get interface pointer 1. IClassFactory::CreateInstance Creating a local object using a class factory Client Application Object ClassFactory Server Component technology
The Component Model Defined • COM interfaces and COM classes • Uniquely identified by GUIDs • A class may implement several interfaces • Several classes may implement the same interface • COM servers • Are either in-process (.dll) or out-of-process (.exe) • A server may implement several classes • The COM library • Used by clients to create COM objects Component technology
Resources • Essential COM, Don Box • Programming Distributed Applications with COM and Ms VB 6.0, Ted Pattison • Fundamentals of COM(+), (Part 1 + 2), ppt presentation by, Don Box • Links • http://www.develop.com/dbox • http://www.microsoft.com/com/ • http://msdn.microsoft.com/library/default.asp?URL=/library/en-us/dnasp/html/comtutorial.asp • http://www.eki.mdh.se/kurshemsidor/informatik/ei0230/com/ht00/index.htm • http://www.codeproject.com/com/ • http://www.microsoft.com/com/news/drgui.asp Component technology
Existent COM Technologies • DCOM Distributed COM • COM + Extension of COM • MSMQ Message Queuing • MTS Microsoft Transaction Server • ActiveX Controls • Distribution of components over high-latency networks • Provide integration of controls into Web browsers Component technology
Useful COM Tools • GUIDGEN.EXE Generates GUID’s • DCOMCNFG.EXE Configuration tool • OLEVIEW.EXE Configuration tool • MIDL.EXE Compiler • REGSVR32.EXE Install & Uninstall in-process server • COM library • OLE32.DLL • core class/interface functionality • OLEAUT32.DLL • Visual Basic®-centric type infrastructure • Environments • FrontPage, Visual Studio, Adobe PageMaker, Borland Intrabuilder etc. Component technology
C++ vs COM • COM as a better C++ • Improved flexibility, extensibility, maintainability. • Binary reuse • C++ • Reuse of user-defined types • Include libraries • CBSE with C++ • Deploy the class as a DLL • Use the notations of interfaces and implementations • Add dynamically selection with e.g LoadLibrary() • Add dynamically interrogation Component technology
C++ vs COM, Cont. • Problems - CBSE with C++ • Clients statically link to import library • Client imports resolved at load time • C++ compilers non-standard for DLLs • DLL and clients must be built using same compiler/linker • Adding new public methods • OK when statically linked • Dangerous to a DLL-based class • New client expects method to be there • Old DLLs have never heard of this method • Change definition of a data type => massive rebuild/redeployment of client/object • Clients must not program in terms of classes • Does not provide a reasonable binary component architecture for encapsulation Component technology
C++ vs COM, Cont. • Interface-based programming • Splits the world into two to solve the replaceable component problem • Define interfaces • The types the client programs against can never change • Since classes need to change, these better not be classes • Encapsulation of implementation • Prevents clients changing the underlying class hierarchy • In C++ • For bridging interfaces and classes • use abstract base (classes as interfaces) Component technology
COM advantages Taking advantage of COM allows you to: • Package your objects in a uniform way as executables or dynamic-link libraries. • Break your application into really reusable components, ones that you can redistribute easily to others. • Be prepared to distribute your components on multiple machines, through a simple change in configuration. As COM is being ported to other platforms, you can even take advantage of real, standardized, efficient interoperability between different platforms. Markus Horstmann, Microsoft. From C++ to COM • COM provides the ability to work with CBSE (Component-Based Software Engineering) which is hard if not impossible in C++ Component technology