Article de reference

Interface (informatique)

En informatique, une interface est une limite partagée permettant à deux ou plusieurs composants distincts d'un système informatique d'échanger des informations. Cet échange peu...

En informatique, une interface est une limite partagée permettant à deux ou plusieurs composants distincts d'un système informatique d'échanger des informations. Cet échange peut avoir lieu entre des logiciels , du matériel informatique , des périphériques , des utilisateurs ou une combinaison de ces éléments. Certains périphériques, comme un écran tactile, peuvent à la fois envoyer et recevoir des données via l'interface, tandis que d'autres, comme une souris ou un microphone, ne servent qu'à transmettre des données à un système donné.

Interfaces matérielles

Interfaces matérielles d'un ordinateur portable : prise réseau Ethernet (au centre), à ​​gauche une partie du port VGA , à droite (en haut) une prise DisplayPort , à droite (en bas) une prise USB -A.

Une interface logicielle peut désigner une grande variété d'interfaces à différents niveaux. Par exemple, un système d'exploitation peut interagir avec des composants matériels. Les applications ou programmes exécutés sur le système d'exploitation peuvent avoir besoin d'interagir via des flux de données , des filtres et des pipelines. Dans les programmes orientés objet , les objets d'une application peuvent avoir besoin d'interagir via des méthodes .

En pratique

A key principle of design is to prohibit access to all resources by default, allowing access only through well-defined entry points, i.e., interfaces. Software interfaces provide access to computer resources (such as memory, CPU, storage, etc.) of the underlying computer system; direct access (i.e., not through well-designed interfaces) to such resources by software can have major ramifications—sometimes disastrous ones—for functionality and stability.

Interfaces between software components can provide constants, data types, types of procedures, exception specifications, and method signatures. Sometimes, public variables are also defined as part of an interface.

The interface of a software module A is deliberately defined separately from the implementation of that module. The latter contains the actual code of the procedures and methods described in the interface, as well as other "private" variables, procedures, etc. Another software module B, for example the client to A, that interacts with A is forced to do so only through the published interface. One practical advantage of this arrangement is that replacing the implementation of A with another implementation of the same interface should not cause B to fail—how A internally meets the requirements of the interface is not relevant to B, which is only concerned with the specifications of the interface. (See also Liskov substitution principle.)

In object-oriented languages

that has the single read() method; various implementations are used for different purposes, including BufferedReader, FileReader, InputStreamReader, PipedReader, and StringReader. Marker interfaces like Serializable contain no methods at all and serve to provide run-time information to generic processing using Reflection.

Programming to the interface

The use of interfaces allows for a programming style called programming to the interface. The idea behind this approach is to base programming logic on the interfaces of the objects used, rather than on internal implementation details. Programming to the interface reduces dependency on implementation specifics and makes code more reusable.

Pushing this idea to the extreme, inversion of control leaves the context to inject the code with the specific implementations of the interface that will be used to perform the work.

User interfaces