EQuestionAnswers.com Computer/Electronics Questions and Answers
C, C++, VC++, COM/DCOM, DLL and more
#Login #Sign up  Facebook Twitter TGoogle+

#Previous question #Index of COM/DCOM Questions #Next question

Factory design pattern

Factory is a design pattern. This design does not allow object allocation and memory management in client side. This is achieved by making the scope of the constructor and destructor as private. A private scope creates compilation error if new or delete operations are used in client's code and thus client side is restricted for memory management. This design provides a class with create function which can return a set of objects to the client. This function is called factory creator entry point. It takes some kind of unique id or name of the class and returns an instance to the client.

Factory in COM/DCOM

All COM/DCOM server follows factory design pattern. This design pattern does not allow object creation using new operator. Object creation and allocation is managed in server side. Object deallocation or free is managed by IUnknown::Release() call.

IClassFactory in COM

Every COM server implements a IClassFactory to fit this design. The creation of the object is abstracted inside COM server and client provides unique identity of the interface class to the server.

IClassFactory::CreateInstance() is the factory creator function it takes interface id /IID as input. Server then creates an instance of the class and returns the instance to the client.

class  IClassFactory : public IUnknown {
    virtual HRESULT __stdcall CreateInstance(
            /* [in] */ IUnknown  *pUnkOuter,
            /* [in] */ REFIID riid,   /* Unique ID of the interface */
            /* [out] */ void **ppvObject /* Output  pointer */
            ) = 0;

You have viewed 1 page out of 66. Your COM/DCOM learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

# COM DCOM Interview Questions and Answers :: ALL Interview .com
# COM DCOM - COM DCOM Interview Questions
# COM interview questions | TechInterviews
# COM Interview Questions - CodeProject
# Com Dcom Interview Questions - Com and Dcom in Asp Net
# ATL Interview Questions and Answers :: ALL Interview .com
# ActiveX Interview Questions and Answers :: ALL Interview .com

* #1 webmaster Mon 28 Apr/2014 18:25:33(GMT)  Like 0 Unlike 0

Dear Users,

We are pleased to inform you that a forum/blog has been incorporated with www.mybestnotes.co.in. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.


Your message goes here:

My Post:*
Secutiry Code: ******  *
Preview this compose before posting this in discussion forum.
  1. Use [Sxx] code to show smiles. Example [S02]
  2. Use [URL ], example [URL http://www.google.com/]
  3. To display code or un formatted text use [CODE] [/CODE]. Example: [CODE] printf("Hello world"); [/CODE]
 [S01]   [S02]   [S03]   [S04]   [S05]   [S06]   [S07]   [S08] 
 [S09]   [S10]   [S11]   [S12]   [S13]   [S14]   [S15]   [S16] 
 [S17]   [S18]   [S19]   [S20]   [S21]   [S22]   [S23]   [S24] 

Note: Only members are allowed, * fields are mandatory.