Map
Index
Random
Help
Topics
th

Topic: interface type

topics > computer science > data > Group: data type



Group:
object-oriented programming
Group:
type inheritance

Topic:
abstract data type
Topic:
abstract functions
Topic:
data type as a set of operations
Topic:
function signature
Topic:
function syntax by pattern
Topic:
generic operations and polymorphism
Topic:
interface between program modules
Topic:
non-hierarchical classification and multiple classification
Topic:
object-oriented classes
Topic:
object-oriented data types
Topic:
object-oriented methods
Topic:
object-oriented prototypes
Topic:
object-oriented templates and containers
Topic:
problems with type inheritance
Topic:
structural equivalence vs. name equivalence of data types
Topic:
type parameter
Topic:
types of object-oriented classes
Topic:
user-defined data type
Topic:
variable as function that accesses an object's value
Topic:
virtual machine

Summary

An interface type defines a set of abstract functions. It does not specify a data structure, nor an implementation. If a parameter is an interface type, only those functions may be used. The corresponding argument must implement each of these functions. For example, a virtual, block-structured device may specify functions for reading and writing blocks. A physical disk driver is an instance of the virtual device if it includes the same functions.

An interface type may informally specify usage rules. For example, a stream interface usually requires opening the stream before using it.

An interface type may specify getters and setters for required fields.

Interface types are widely used for object-oriented programming. Single inheritance with interface types provides much of the flexibility of multiple inheritance. Generic programming restricts all parameters to interface types.

A mixin class is somewhat similar. It adds functionality as well as a functional interface. (cbb 7/06)

Subtopic: abstract interface up

Quote: a virtual device is a device-independent interface to device-dependent code; allows change without rewriting user programs [»britKH3_1981]
Quote: the type of an object is its external interface, while the class of an object is its implementation

Subtopic: advantages of interface up

Quote: prefer interfaces over inheritance; unless designed for inheritance, avoid using methods that may be overridden [»blocJ_2001]
Quote: prefer interfaces over abstract classes; easy migration, easy mixins, easily wrapped for enhancements, nonhierarchical [»blocJ_2001]
Quote: define parameters as interfaces instead of classes; greater flexibility without copy operations [»blocJ_2001]
Quote: only refer to an object's class when creating it; use interfaces elsewhere [»blocJ_2001]
Quote: use reflection to create objects and use their interface or superclass for access [»blocJ_2001]
Quote: use interface types for parameters, return values, variables, and fields

Subtopic: interface as contract, assumptions up

Quote: an abstract interface represents the assumptions provided by a collection of device interfaces; it reveals some, but not all, properties of an actual device [»britKH3_1981]
Quote: an abstract interface consists of an assumption list and programming constructs; the two must be consistent [»britKH3_1981]
Quote: use abstract classes to decouple contract from implementation; use interfaces to define invariant contracts [»cwalK_2006]
Quote: write interface assumptions in prose; errors seldom occurred in both assumptions and programming constructs [»britKH3_1981]
Quote: a Larch interface specification has the type name, public routines, a trait, mapping of types to the trait, and routine specifications [»guttJV9_1985]
Quote: template concepts restrict the allowable types; e.g., Assignable with Assignable as true [»dosrG1_2006]
Quote: define use patterns that a type must implement; e.g., 'p++=v' or 'bool b = (p != q);' [»dosrG1_2006]
Quote: use patterns, like C++ expressions, are more abstract and readable than an equivalent set of operations and auxiliary types [»dosrG1_2006]

Subtopic: type by fields or interface up

Quote: variant-type -- a type could be all data structures that contain name and birth-date fields [»parnDL3_1976]
Quote: a procedure can specify that a parameter has an 'insert' operator; allows use of 'insert'; enforced [»joneAK4_1976]
Quote: instead of an argument having rights to use a function, Russell requires the appropriate field [»demeA_1978]
Quote: annotate a type parameter with a needs specification to restrict a variable without defining a new type [»mitcJG_1977]
Quote: changing the qualifying rights for an element of a data structure changes its type [»joneAK4_1976, OK]

Subtopic: type as interface up

Note: any type defines an interface; those functions that use it as a parameter [»cbb_1990, OK]

Subtopic: interface inheritance up

Quote: encapsulation and interface inheritance are useful features of object-oriented programming [»oustJK3_1998]
Quote: a virtual CLR method may be final (no derivation), new (parent method accessible), abstract (no implementation); interface methods are virtual [»hamiJ2_2003]

Subtopic: inferred type up

Quote: all types may be inferred in CPL; allows any data source to be used as long as the inferred type and actual structure are compatible [»wongL9_2000]

Subtopic: immutability up

Quote: writing new code is natural with reference immutability; helped define interfaces; easier than annotating existing code [»birkA10_2004]

Subtopic: abstract skeletal implementation up

Quote: provide an abstract skeletal implementation for each nontrivial interface; e.g., AbstractList; simplifies implementation [»blocJ_2001]

Subtopic: multiple inheritance up

Quote: in object-oriented programming, multiple inheritance is very useful; if not provided, it is approximated [»wolfW9_1989]
Quote: CLR uses single inheritance with multiple interfaces; all interface methods must be implemented [»hamiJ2_2003]
Quote: single dispatching encourages the definition of abstract data types; multiple dispatching does not [»taivA9_1996]

Subtopic: interface for polymorphic operations up

Quote: dynamic binding allows a class to manipulate polymorphic entities without testing the type; e.g., t.postorder traverses many kinds of trees [»meyeB9_1990]
Quote: Sketchpad can perform basic operations on any drawing part (e.g., display); allows changing the specific details without changing the general parts [»suthIE5_1963]

Subtopic: interface as indirect call up

Note: an interface is an indirect call through a field of a function table using a standard calling convention [»cbb_2000, OK]

Subtopic: interface as operations up

Quote: the external view of an object is its protocol, i.e., the set of messages that it responds to [»robsD8_1981]
Quote: the type of an object is its operations; a type error occurs when an object does not have a method for a message [»rodrNR8_1993]
Quote: the type of an object is its external interface, while the class of an object is its implementation

Subtopic: distinguished types via properties/interface up

Quote: use properties to distinguish types that have the same operations; e.g., the property 'LIFO' for type 'stack'; simulate with dummy functions [»rodrNR8_1993]

Subtopic: consistent naming up

Quote: Eiffel uses consistent names across classes; e.g., use 'add' instead of 'push' for STACK [»meyeB9_1990]

Subtopic: data interfaces up

Quote: use pointers to data members to express the layout of a C++ class in an implementation-independent manner [»stroB_1994]

Subtopic: generic module of interfaces only up

Quote: a generic module in Module-3 only takes interfaces as parameters; independent, typechecked compilation [»nelsG_1991]
Quote: Modula-3's generics interact with interfaces and modules, not with the type system; avoids complications of every construct accepting every kind of entity as a parameter [»nelsG_1991]

Subtopic: mixin up

Quote: a mixin class implements properties solely for use in other classes; create a new class by combining mixins [»taivA9_1996]
Quote: a Ruby mix-in is an interface that includes code; e.g., 'find' for 'Enumerable'; implemented as a module

Subtopic: exception up

Quote: the header of a CLU procedure specifies how it can terminate; i.e., its signals and return results [»liskBH11_1979]

Subtopic: implementation up

Quote: use a hashed, interface method table for efficient interface dispatch; comparable to a virtual method call [»alpeB10_2001]
Quote: Smalltalk-80 assigned a method dictionary to each class-describing object; associates selectors with methods [»krasG8_1981]
Quote: efficient interface dispatch (invokevirtual) using fixed-sized, interface method tables, disambiguated by a interface method signature; used by Jalapeno [»alpeB6_2001]

Subtopic: problems with interfaces up

Quote: an abstract class is easier to evolve than an interface; can not add methods to a public interface [»blocJ_2001]
Quote: class-based APIs are easier to modify than interface-based APIs; can add members to classes as needed [»cwalK_2006]
Quote: can not change a widely implemented interface; for a new interface, create many test implementations
[»blocJ_2001]

Related Topics up

Group: object-oriented programming   (26 topics, 822 quotes)
Group: type inheritance   (13 topics, 394 quotes)

Topic: abstract data type (64 items)
Topic: abstract functions (11 items)
Topic: data type as a set of operations (38 items)
Topic: function signature (21 items)
Topic: function syntax by pattern (15 items)
Topic: generic operations and polymorphism (67 items)
Topic: interface between program modules (55 items)
Topic: non-hierarchical classification and multiple classification (16 items)
Topic: object-oriented classes (67 items)
Topic: object-oriented data types (29 items)
Topic: object-oriented methods (42 items)
Topic: object-oriented prototypes (39 items)
Topic: object-oriented templates and containers (27 items)
Topic: problems with type inheritance (20 items)
Topic: structural equivalence vs. name equivalence of data types (30 items)
Topic: type parameter (34 items)
Topic: types of object-oriented classes (18 items)
Topic: user-defined data type (13 items)
Topic: variable as function that accesses an object's value (21 items)
Topic: virtual machine
(13 items)


Updated barberCB 9/05
Copyright © 2002-2008 by C. Bradford Barber. All rights reserved.
Thesa is a trademark of C. Bradford Barber.