Recent

Author Topic: A few questions about Interfaces : Part 2  (Read 7215 times)

vfclists

  • Hero Member
  • *****
  • Posts: 824
    • HowTos Considered Harmful?
A few questions about Interfaces : Part 2
« on: March 06, 2016, 12:03:31 am »
What is the role of the GUID in interfaces? Given their uniqeuness does that mean that once you compile an interface you shouldn't change the interface definition again?

Is the GUID actually necessary and is it only required on Windows?
Windows - Lazarus 1.0.8/FPC 2.6.0
Linux - Lazarus 1.4.4 /FPC 2.6.4

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: A few questions about Interfaces : Part 2
« Reply #1 on: March 06, 2016, 06:23:44 am »
GUID is the interface's ID with out a GUID and interface can't be identified at all. It is there to avoid using or embosing a language's internals to the others, and it is used to find or created an object that implements the interface . Corba interfaces have a plain string as Id instead of a GUID which can have what ever form you like but I do prefer the GUID idea and probably I will use it on corba interfaces too.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Basile-B

  • Sr. Member
  • ****
  • Posts: 457
    • GH...
Re: A few questions about Interfaces : Part 2
« Reply #2 on: March 06, 2016, 06:38:05 am »
with CORBA interfaces, the GUID is completly optional since you'll never use it, in this case you just extract an interface with as and the type.
It's not like with QueryInterface() and COM that need to work in an language-agnostic fashion.

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: A few questions about Interfaces : Part 2
« Reply #3 on: March 06, 2016, 06:45:46 am »
with CORBA interfaces, the GUID is completly optional since you'll never use it, in this case you just extract an interface with as and the type.
It's not like with QueryInterface() and COM that need to work in an language-agnostic fashion.
Does that mean that corba interfaces are not language agnostic? in sort I can't have interface implemented in other languages than the one the consumer is written in? Sorry but my corba interface knowledge is minimal.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 8199
Re: A few questions about Interfaces : Part 2
« Reply #4 on: March 06, 2016, 08:32:05 am »
Does that mean that corba interfaces are not language agnostic? in sort I can't have interface implemented in other languages than the one the consumer is written in? Sorry but my corba interface knowledge is minimal.

No. just like with COM interfaces there is an IDL description that is language agnostic. If anything CORBA is more language agnostic and platform agnostic than COM.
There a good write up in wikipedia:
https://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture
« Last Edit: March 06, 2016, 08:38:56 am by Thaddy »
Read the manuals and if you are a professional get a proper education in computer science. Makes the forum a lot cleaner.

Zoran

  • Hero Member
  • *****
  • Posts: 1426
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: A few questions about Interfaces : Part 2
« Reply #5 on: March 06, 2016, 08:42:34 am »
I still do not understand why this GUID.
I do understand interfaces as described in article which vfclist links to in his other topic - http://www.delphibasics.co.uk/Article.asp?Name=Interface
I do understand well that this is very useful.

Note that in that article guids are not used!

And then this two posts are more confusing:
with CORBA interfaces, the GUID is completly optional since you'll never use it, in this case you just extract an interface with as and the type.
It's not like with QueryInterface() and COM that need to work in an language-agnostic fashion.
Does that mean that corba interfaces are not language agnostic? in sort I can't have interface implemented in other languages than the one the consumer is written in? Sorry but my corba interface knowledge is minimal.

Before Object Pascal, I learned about interfaces in Java (with Java I learned object oriented programming). In Java they are much more used then in Object pascal. But I have NEVER seen GUIDs in Java.

What do you mean by "language agnostic"? Are you talking about using interfaces declared in pascal in other languages? How? In which languages? C++, Java? And why? Why would you need interfaces from one language to use in another?



taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: A few questions about Interfaces : Part 2
« Reply #6 on: March 06, 2016, 09:06:36 am »
I still do not understand why this GUID.
I do understand interfaces as described in article which vfclist links to in his other topic - http://www.delphibasics.co.uk/Article.asp?Name=Interface
I do understand well that this is very useful.

Note that in that article guids are not used!

And then this two posts are more confusing:
with CORBA interfaces, the GUID is completly optional since you'll never use it, in this case you just extract an interface with as and the type.
It's not like with QueryInterface() and COM that need to work in an language-agnostic fashion.
Does that mean that corba interfaces are not language agnostic? in sort I can't have interface implemented in other languages than the one the consumer is written in? Sorry but my corba interface knowledge is minimal.

Before Object Pascal, I learned about interfaces in Java (with Java I learned object oriented programming). In Java they are much more used then in Object pascal. But I have NEVER seen GUIDs in Java.

What do you mean by "language agnostic"? Are you talking about using interfaces declared in pascal in other languages? How? In which languages? C++, Java? And why? Why would you need interfaces from one language to use in another?
Yes when I say language agnostic I do mean that in interfaces defined in C++ can be implemented in pascal or basic and used from C++ basic, python, java, or any languages that has library to support them. It is the most usable feature of interfaces it is the feature that used to allow activeX controls to be used from any language including pascal, java etc. A framework build as language agnostic will have to follow very tight specifications it is the same as you writing a dll using only C data types but object oriented. 
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Zoran

  • Hero Member
  • *****
  • Posts: 1426
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: A few questions about Interfaces : Part 2
« Reply #7 on: March 06, 2016, 10:58:55 am »
All tutorials about interfaces talk about them like abstract classes, from which then different classes can inherit common functionality.
But, if I understand correctly, apart from this, interfaces have another completely different purpose?

I still do not understand much about using it in different languages and I am not very interested in that now... but, are these GUIDs actually only for that?

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: A few questions about Interfaces : Part 2
« Reply #8 on: March 06, 2016, 11:06:44 am »
All tutorials about interfaces talk about them like abstract classes, from which then different classes can inherit common functionality.
But, if I understand correctly, apart from this, interfaces have another completely different purpose?
In pascal interfaces is the only working mechanism for "multiple inheritance" as well

I still do not understand much about using it in different languages and I am not very interested in that now... but, are these GUIDs actually only for that?
For what exactly? As far as I know the role of an ID is to uniquely identify an interface. GUIDs were created in order to make sure that each ID was globally unique avoiding using a registry and all the problems that come with it.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 8199
Re: A few questions about Interfaces : Part 2
« Reply #9 on: March 06, 2016, 11:12:16 am »
Well, look at it this way:
Both in CORBA as in COM there is an intermediate Interface Description Language (IDL) that describes how to translate what is described (in IDL) into a native language like C++ or Object Pascal.

Both Delphi and Freepascal hide that intermediate step for you. That may put you on the wrong foot.

If you really want to use CORBA and not a seasoned programmer forget about GUID's altogether.
And forget about ActiveX supporting CORBA. It doesn't. ActiveX supports COM, which NEEDS GUID's (most of the time) and works completely different. And you didn't read the wiki entry I posted here...
If you want to understand, read references, although asking questions might help. But do something with the answers.
Read the manuals and if you are a professional get a proper education in computer science. Makes the forum a lot cleaner.

Zoran

  • Hero Member
  • *****
  • Posts: 1426
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: A few questions about Interfaces : Part 2
« Reply #10 on: March 06, 2016, 11:14:46 am »
As far as I know the role of an ID is to uniquely identify an interface. GUIDs were created in order to make sure that each ID was globally unique avoiding using a registry and all the problems that come with it.

Sorry, I am not following... What ID? What identifying? Without ID, what would you use a registry for?

See the article with which we started "The reason for interfaces" - no IDs, no GUIDs. Also, in Java tutorial, section about interfaces, again no IDs, no GUIDs.
And I do not see problem with identifying interface

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: A few questions about Interfaces : Part 2
« Reply #11 on: March 06, 2016, 11:23:41 am »
As far as I know the role of an ID is to uniquely identify an interface. GUIDs were created in order to make sure that each ID was globally unique avoiding using a registry and all the problems that come with it.

Sorry, I am not following... What ID? What identifying? Without ID, what would you use a registry for?

See the article with which we started "The reason for interfaces" - no IDs, no GUIDs. Also, in Java tutorial, section about interfaces, again no IDs, no GUIDs.
And I do not see problem with identifying interface
So how do you propose to ask for a specific interface from a factory for instance?Please keep in mind that you do not write the factory nor have access to its code.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Zoran

  • Hero Member
  • *****
  • Posts: 1426
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: A few questions about Interfaces : Part 2
« Reply #12 on: March 06, 2016, 11:26:38 am »
So how do you propose to ask for a specific interface from a factory for instance?

What factory?

I am sorry, I just do not follow. :-[

Zoran

  • Hero Member
  • *****
  • Posts: 1426
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: A few questions about Interfaces : Part 2
« Reply #13 on: March 06, 2016, 11:30:19 am »
Please keep in mind that you do not write the factory nor have access to its code.

Okay, I guess there is much more about interfaces that is not covered in mentioned tutorials. Sorry, thank you for trying to answer.
This is obviously some different matter from just what is described in those articles.

Thaddy

  • Hero Member
  • *****
  • Posts: 8199
Re: A few questions about Interfaces : Part 2
« Reply #14 on: March 06, 2016, 11:44:18 am »
As far as I know the role of an ID is to uniquely identify an interface. GUIDs were created in order to make sure that each ID was globally unique avoiding using a registry and all the problems that come with it.

Sorry, I am not following... What ID? What identifying? Without ID, what would you use a registry for?

See the article with which we started "The reason for interfaces" - no IDs, no GUIDs. Also, in Java tutorial, section about interfaces, again no IDs, no GUIDs.
And I do not see problem with identifying interface
Ah I see. you are not familiar with the meaning of the English language word "interface" which simply means a way to communicate.
See for a more specific explanation regarding computing https://en.wikipedia.org/wiki/Interface_%28computing%29.
Point is: in java it has again different semantics from CORBA or even more different from COM.
Three ways to solve a problem. So basically, you are confused because not every type of interface is the same interface type.
It is not really that hard.
Read the manuals and if you are a professional get a proper education in computer science. Makes the forum a lot cleaner.