HOME

TheInfoList



OR:

Interface-based programming, also known as interface-based architecture, is an
architectural pattern An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. The architectural patterns address various issues in software engineering, such as computer hardware perfor ...
for implementing
modular programming Modular programming is a software design technique that emphasizes separating the functionality of a Computer program, program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of th ...
at the
component Circuit Component may refer to: •Are devices that perform functions when they are connected in a circuit.   In engineering, science, and technology Generic systems * System components, an entity with discrete structure, such as an assem ...
level in an
object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
language which does not have a module system. An example of such a language is
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
, which (), does not have a module system at the level of components. Java has a ''package'' system, but Java software components typically consist of multiple
Java package A Java package organizes Java classes into namespaces, providing a unique namespace for each type it contains. Classes in the same package can access each other's package-private and protected members. In general, a package can contain the follo ...
s and in any case, interface programming can provide advantages over merely using Java packages, even if a component only consists of a single Java package. Interface-based programming defines the application as a collection of components, in which
Application Programming Interface An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
(API) calls ''between'' components may only be made through abstract interfaces, not concrete classes. Instances of classes will generally be obtained through other interfaces using techniques such as the
Factory pattern In object-oriented programming, a factory is an object for creating other objects; formally, it is a function or method that returns objects of a varying prototype or class from some method call, which is assumed to be "new". More broadly, a s ...
. This is claimed to increase the ''modularity'' of the application and hence its
maintainability In engineering, maintainability is the ease with which a product can be maintained to: * correct defects or their cause, * Repair or replace faulty or worn-out components without having to replace still working parts, * prevent unexpected working ...
. However, some caution is warranted merely splitting an application into arbitrary components communicating via interfaces does not ''in itself'' guarantee low
coupling A coupling is a device used to connect two shafts together at their ends for the purpose of transmitting power. The primary purpose of couplings is to join two pieces of rotating equipment while permitting some degree of misalignment or end mov ...
or high cohesion, two other attributes that are commonly regarded as key for maintainability. An interface-based architecture can be used when third parties or indeed separate teams within the same organisation develop additional components or plugins for an established system. The codebase of the
Eclipse IDE Eclipse is an integrated development environment (IDE) used in computer programming. It contains a base workspace and an extensible plug-in system for customizing the environment. It is the second-most-popular IDE for Java development, and, ...
is an example of interface-based programming. Eclipse plugin vendors just have to develop components that satisfy the interface specified by the parent application vendor, the Eclipse Foundation. Indeed, in Eclipse, even the original components such as the Java Development Tools are ''themselves'' plugins. This is somewhat like a
mobile phone A mobile phone, cellular phone, cell phone, cellphone, handphone, hand phone or pocket phone, sometimes shortened to simply mobile, cell, or just phone, is a portable telephone that can make and receive calls over a radio frequency link whi ...
manufacturer specifying a mobile charger interface (pin arrangement, expected
direct current Direct current (DC) is one-directional flow of electric charge. An electrochemical cell is a prime example of DC power. Direct current may flow through a conductor such as a wire, but can also flow through semiconductors, insulators, or ev ...
voltage, etc.) and both the manufacturer and third parties making their own mobile phone chargers that comply with this standard interface specification.


Software evolution in interface-based programming

The use of
interfaces Interface or interfacing may refer to: Academic journals * ''Interface'' (journal), by the Electrochemical Society * '' Interface, Journal of Applied Linguistics'', now merged with ''ITL International Journal of Applied Linguistics'' * '' Int ...
to allow disparate teams to collaborate raises the question of how interface changes happen in interface-based programming. The problem is that if an interface is changed, e.g. by adding a new method, old code written to implement the interface will no longer compile and in the case of dynamically-loaded or linked plugins, will either fail to load or link, or crash at runtime. There are two basic approaches for dealing with this problem: # a new interface may be developed with additional functionality, which might inherit from the old interface # a
software versioning Software versioning is the process of assigning either unique ''version names'' or unique ''version numbers'' to unique states of computer software. Within a given version number category (e.g., major or minor), these numbers are generally assig ...
policy such a
semantic versioning 2.0
may be communicated to interface implementors, to allow forward-incompatible, or even backward-incompatible, changes in future "major" versions of the platform Both of these approaches have been used in the Java platform.


Design by contract

The publisher of the interfaces generally promises that they will not change the interface in new "minor" versions of the software, and the implementer, by implementing the interface, implies that they have implemented at least the required parts of the interface without any deviation. An interface can therefore be viewed as a "contractual agreement"{{spaced ndash between a provider and a consumer of the interface. If this contract is documented more formally as a software specification, this is an example of design by contract. However, design by contract ''per se'' does not mandate the use of interfaces for all components.


See also

*
Microservices A microservice architecture – a variant of the service-oriented architecture structural style – is an architectural pattern that arranges an application as a collection of loosely-coupled, fine-grained services, communicating through lightwe ...
*
Actor model The actor model in computer science is a mathematical model of concurrent computation that treats ''actor'' as the universal primitive of concurrent computation. In response to a message it receives, an actor can: make local decisions, create mor ...
*
CORBA The Common Object Request Broker Architecture (CORBA) is a standard defined by the Object Management Group (OMG) designed to facilitate the communication of systems that are deployed on diverse platforms. CORBA enables collaboration between s ...
, an older component-based system for object-oriented software which is now rarely used, for various reasons


References


C# Interface Based Development
c-sharpcorner.com
Interface Based Development – The Unified Modeling Language (UML)
devmentor.org
Architecting a large application with interface-based architecture
rhyous.com, 18 October 2011
Understanding Interface-based Programming
Microsoft Developers Network, accessed 16 September 2016 Architectural pattern (computer science)