Click to See Complete Forum and Search --> : Interface Classes..Missed somthing? (NOT RESOLVED)
Rdn
Aug 28th, 2002, 02:35 PM
As I have understood..
Interface classes are used inside COM components, inorder for the developer to maintain CallBack procedures, these callbacks are notifications sent between the client and the server.
Implementing interface classes requiers that the class contains only the definition of the methods and procedures, while the acting code is in a class contained in the client application.
And as I have understood, the most significant advantage using COM components, is the ease of update, that is, you update the server only in one place, rather than updating each client application.
Here rises the question:
In case of using Interface Classes, don't we loose that significant advantage?
jim mcnamara
Aug 28th, 2002, 03:43 PM
Your definitions seem consfused. To me ,anyway.
COM classes are external (in a server: dll, .cls module, or .EXE)
to the client. The client requests a connection (instance). Part of Windows, called the SCM, makes the connection for the client by mapping the COM server into client memory space. So, the COM server lives, for a while, sharing memory in the client process.
IF the server is an EXE then the SCM sets up marshaling (sending data via proxy back & forth between the client & the server). It doesn't map the server into the process memory in this case.
Interface definitions are: a list of pointers to functions. That's all.
It's a VTABLE in C++. They are meant to be purely binary, to the point where the client cannot know anything about the server (and vice-versa) except what function(s) the interface provides.
Plus, the client has to know how to call the function (parameters,datatypes, etc) in the interface. The server does not provide this information, unless there is a type library associated with the server. If you don't want somebody to use your COM server (after all, you wrote it) do not provide type library information. Your stuff is safe from pirates.
Rdn
Aug 29th, 2002, 06:28 AM
I think I have not explained my idea clearly.The follwing illustration makes it clear:
Interface Class:
'Class name: IClass1
Public Sub Method1
End Sub
Public Sub Method2
End Sub
Public Function Add (Byval sng1 As Single, Byval sng2 As Single) As Single
End Function
Client side class:
Option Explicit
'Class name: cMathmatics
Implements IClass1
Public Sub Method1
'Do somethign
End Sub
Public Sub Method2
'Do something else
End Sub
Public Function Add (Byval sng1 As Single, Byval sng2 As Single) As Single
'Add sng1 to sng2
End Function
Using the interface class in Form1
Dim x As cMathmatics
Dim y As IClass1
Private Sub Command1_Click
Set x = New cMathmatics
Set y = New x
Text1.Text = y.Add(3.5,14.6)
End Sub
In this case, when you want to update, you have to update all client side classes. and this was my question.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.