I have a few posts coming up about various coding stuff so I thought I would lay some of the groundwork.
An interface is the bit of something that gets exposed so you can interact with the bit that actually does the work. The classic example is a video recorder, the interface being the play/rewind buttons that we use to control whatever goes on inside, which most of us neither know or care about.
Same with a car, the interface is the driver controls, we don’t care about the engine, just that it wheelspins in 3rd when you hoof it. (must have been an ice patch officer (in July))
From a code point of view the interface is the set of externally accessible functions, variables, properties, methods, subs, or whatever. Some might only be accessible within the same project, some might be accessible from totally separate bits of code.
Same project is easy enough we often do that with public subs in modules in VBA. Making stuff visible from a different component though is a bit more challenging, especially in VBA, but the principle is the same.
Those nice people at Microsoft equipped Excel with several sets of externally accessible functions. One is the C API, this Application Programming Interface follows the C calling convention, and cannot be accessed by VB as VB doesn’t do the C calling convention. In fact this set of functions can only be accessed by real native code components so is out of (direct) reach of .net etc. I am going to cover this stuff in more detail as time goes on.
The other interface Excel exposes is a COM one, COM is much less picky than C so a great many languages can talk to Excel via this interface. VBA is probably the most common, but most languages can do it using something similar to CreateObject(‘Excel.Application’) and then navigating the object model just as we do in VBA. I’m going to cover this later too, which could be fun.
The most useful point about interfaces is that they can stay stable whilst all the stuff in the background gets changed. (This is what that binary compatibility malarky was in VB6 – get that wrong and you eventually crashed your registry – anyone else do that?).
So in rough summary:
interface = bunch of procedures and variables that can be seen from outside.
stable interface = good, frequent interface changes = bad (all clients affected)
Feel free to add or remove or correct in the comments
cheers
Simon