Would it be correct to say that for an object to implement a certain interface means that its supports a number of Procedureal Types of 'procedure of object' items, the main difference being that their names are known beforehand?
Does a unit which depends on the interfaced object need to be compiled with that unit, or does need only a unit where that interface type is declared?
Taking this code posted at
http://www.delphibasics.co.uk/Article.asp?Name=Interface :
type
// An interface definition
IRecyclable = Interface(IInterface)
// A single function supporting the property
function GetIsRecyclable : Boolean;
// A single property
property isRecyclable : Boolean read GetIsRecyclable;
end;
Say the above snippet is in unit A and some routine in unit B needs to use an object TSomeObject from unit C which implements IRecyclable.
Is it necessary for unit B to be compiled with support for unit C if the routine in unit B needs to use
only the IRecyclable properties of TSomeObject, but not the remaining properties? Say some code in B is passed a parameter of an unknown type such as TSomeObject that implements IRecyclable and has some code like :
if var is IRecyclable then
if var.IsRecylable then
...
Is this one of the main rationales for interfaces?