Unsure of the relationship between and difference in use of classes versus interfaces | developer.brewmp.com Unsure of the relationship between and difference in use of classes versus interfaces | developer.brewmp.com

Developer

Unsure of the relationship between and difference in use of classes versus interfaces

Forums:

Hello

The relationship and use of classes and interfaces isn't clear to me. For example, I want to use some telephony features, and looking at this page https://developer.brewmp.com/reference/api/brew-315/itapi there is one class and 9 interfaces described. So the implication is a single class can implement multiple interfaces.

So in my code, do I declare and use a class or an interface? If I want to use te ITAPI interface do I declare and create an interface for that specifically, or more generally the class in which it is implemented? And is this done using a class id or an interface id?

 

I've currently implemented some socket code which works, with this I declare an ISockPort which is an interface, yet to use it I use ISHELL_CreateInstance using AEECLSID_SockPort. Doesn't CLSID stand for class id not interface ID? So why therefore am I creating it using a class id and not an interface id?

When are class ids used and when are interface ids used?

In a nutshell, interfaces define a "contract" for calling conventions.   They can't be instantiated directly.
 
Classes are said to "implement an interface" when they are coded to adhere to a specified interface.  Classes in the Brew system are usually created by a "CreateInstance" call but may sometimes also be instantiated by a "factory class".   CreateInstance calls take a class ID as a parameter.  Factory classes don't ordinarily need a class id passed in, what they create is inherent in their implementation.
 
For simple applets and extensions, one typically only needs to reference interface ID's in the implementation of the QueryInterface method.
 
It is indeed possible for a class to implement more than one interface but the current IDE and IDL tools provide no direct support for creating classes with such functionality (someone please correct me if I am wrong).
Hope this helps and maybe gives up enough clues to help you dig through the docs with more understanding..
Jerry.

In a nutshell, interfaces define a "contract" for calling conventions.   They can't be instantiated directly.
 
Classes are said to "implement an interface" when they are coded to adhere to a specified interface.  Classes in the Brew system are usually created by a "CreateInstance" call but may sometimes also be instantiated by a "factory class".   CreateInstance calls take a class ID as a parameter.  Factory classes don't ordinarily need a class id passed in, what they create is inherent in their implementation.
 
For simple applets and extensions, one typically only needs to reference interface ID's in the implementation of the QueryInterface method.
 
It is indeed possible for a class to implement more than one interface but the current IDE and IDL tools provide no direct support for creating classes with such functionality (someone please correct me if I am wrong).
Hope this helps and maybe gives up enough clues to help you dig through the docs with more understanding..
Jerry.