Table of Contents
Interface Definition
Return to Interface declaration
Definitions vs Declarations, Definitions and Declarations (computer programming): Type definition - User-defined type definition, Variable definition - Constant definition, Class definition - Object definition, Constructor definition - Destructor definition, Struct definition - Record definition, Function definition - Method definition, Lambda definition - Anonymous function definition, Enumerator definition, Pointer definition, Generic definition - Template definition, Interface definition - Protocol definition - Trait definition, Namespace definition - Package definition - Module definition - Alias definition - Import definition - Export definition, Macro definition. Programming terms. (navbar_definition)
- Snippet from Wikipedia: Interface (object-oriented programming)
In object-oriented programming, an interface or protocol type is a data type that acts as an abstraction of a class. It describes a set of method signatures, the implementations of which may be provided by multiple classes that are otherwise not necessarily related to each other. A class which provides the methods listed in a protocol is said to adopt the protocol, or to implement the interface.
If objects are fully encapsulated then the protocol is the only way in which they may be accessed by other objects. For example, in Java, the
Comparable
interface specifies a methodcompareTo()
which implementing classes must implement. This means that a sorting method, for example, can sort a collection of any objects of types which implement the Comparable interface, without having to know anything about the inner nature of the class (except that two of these objects can be compared by means ofcompareTo()
).Some programming languages provide explicit language support for protocols (Ada, C#, D, Dart, Delphi, Go, Java, Logtalk, Object Pascal, Objective-C, OCaml, PHP, Racket, Seed7, Swift, Python 3.8). In languages supporting multiple inheritance, such as C++, interfaces are implemented as abstract classes.
In languages without explicit support, protocols are often still present as conventions. This is known as duck typing. For example, in Python, any class can implement an
__iter__
method and be used as a collection.Type classes in languages like Haskell, or module signatures in ML and OCaml, are used for many of the things that protocols are used for.
In Rust, interfaces are called traits.
Language Specifics
1. Bash Scripting
2. C Language
3. C++
4. C#
5. Clojure
6. COBOL
- COBOL interface definition on IBM.com/docs
7. Dart
8. Elixir
9. Fortran
- Fortran interface definition on IBM.com/docs
10. Go
11. Groovy
12. Haskell
13. IBM REXX
- REXX interface definition on IBM.com/docs
14. IBM JCL
- JCL interface definition on IBM.com/docs
15. Java
16. JavaScript
17. Kotlin
18. PHP
19. PowerShell
20. Python
21. Ruby
22. Rust
23. Scala
24. Swift
25. Microsoft T-SQL
26. TypeScript
Search
- Snippet from Wikipedia: Declaration (computer programming)
In computer programming, a declaration is a language construct specifying identifier properties: it declares a word's (identifier's) meaning. Declarations are most commonly used for functions, variables, constants, and classes, but can also be used for other entities such as enumerations and type definitions. Beyond the name (the identifier itself) and the kind of entity (function, variable, etc.), declarations typically specify the data type (for variables and constants), or the type signature (for functions); types may also include dimensions, such as for arrays. A declaration is used to announce the existence of the entity to the compiler; this is important in those strongly typed languages that require functions, variables, and constants, and their types to be specified with a declaration before use, and is used in forward declaration. The term "declaration" is frequently contrasted with the term "definition", but meaning and usage varies significantly between languages; see below.
Declarations are particularly prominent in languages in the ALGOL tradition, including the BCPL family, most prominently C and C++, and also Pascal. Java uses the term "declaration", though Java does not require separate declarations and definitions.
Also Listed As
© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers
SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.