CSC/ECE 517 Fall 2009/wiki3 13 b5: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(creating the page)
 
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Principle of Explicit Interfaces ==
= Principle of Explicit Interfaces =
 
== Definition ==
 
The Principle of Explicit Interfaces is proposed by Bertrand Meyer in his book Object-Oriented Software Construction.  It states
 
<blockquote>"Whenever two modules A and B communicate, this must be obvious from the text of A or B or both."</blockquote>
 
== Motivation ==
 
The Principle of Explicit Interfaces refers to the attempt to ensure that relationships between separate modules are easily found and understood.  This is important when considering making a change to the code base.  It allows the programmer to quickly see what other modules his work might impact, preventing unintended side effects.
 
Interaction between modules, either by direct manipulation or by shared data, is an example of [http://en.wikipedia.org/wiki/Coupling_%28computer_science%29 coupling].  Coupling is a trait of object oriented software that should be avoided when possible, but when it is unavoidable the Principle of Explicit Interfaces should be used to make it as apparent as possible.  This helps to reduce the impact that coupling may have.
 
== Application ==
 
One area in which it may be difficult to implement interfaces while adhering to the principle of explicit interfaces is shared data.  Bertrand Meyer recognizes this problem and diagrams it as:
 
[[Image:Principle_of_Explicit_Interfaces_Data_Sharing.png]]
 
This illustrates how two modules may interact in an indirect manner.  Although the two modules do not directly interact on each other, by relying on a common resource changes to module A may impact how module B functions.
 
== Relationship to Design by Contract ==
 
[http://en.wikipedia.org/wiki/Design_by_contract Design by Contract] is another concept pioneered by Bertrand Meyer relating to the concept of having modules which act in well defined and predictable manners.  This allows other modules to interact with them and get the results they expect.
 
Explicit interfaces is an important part of the contract, since it deals directly with interactions between modules being transparent and easy to spot.  Knowing interactions between modules is essential when making a contract or guarantee for the implementing module's behavior.
 
== External Links ==
 
[http://www.cit.gu.edu.au/~francis/sa2000/unit2.htm#CRITERIA Notes on application architecture] - In addition to a summary of the principle of explicit interfaces, this site has information on Meyer's other principles, and some other important criteria for good application design.
 
[http://en.wikipedia.org/wiki/Object-Oriented_Software_Construction Object-Oriented Software Construction at Wikipedia] - For more information on the text in which the principle was introduced.
 
[http://se.ethz.ch/~meyer/ Bertrand Meyer's home page] - Find other publications and research by Meyer.
 
[http://en.wikipedia.org/wiki/Design_by_contract Design by Contract at Wikipedia] - Other aspects of Design by Contract outside of the principle of explicit interfaces.
 
== Sources ==
 
*Meyer, Bertrand.  Object-Oriented Software Construction, 2nd edition p50.  ISE Inc., Santa Barbara, CA, 1997.

Latest revision as of 21:06, 18 November 2009

Principle of Explicit Interfaces

Definition

The Principle of Explicit Interfaces is proposed by Bertrand Meyer in his book Object-Oriented Software Construction. It states

"Whenever two modules A and B communicate, this must be obvious from the text of A or B or both."

Motivation

The Principle of Explicit Interfaces refers to the attempt to ensure that relationships between separate modules are easily found and understood. This is important when considering making a change to the code base. It allows the programmer to quickly see what other modules his work might impact, preventing unintended side effects.

Interaction between modules, either by direct manipulation or by shared data, is an example of coupling. Coupling is a trait of object oriented software that should be avoided when possible, but when it is unavoidable the Principle of Explicit Interfaces should be used to make it as apparent as possible. This helps to reduce the impact that coupling may have.

Application

One area in which it may be difficult to implement interfaces while adhering to the principle of explicit interfaces is shared data. Bertrand Meyer recognizes this problem and diagrams it as:

This illustrates how two modules may interact in an indirect manner. Although the two modules do not directly interact on each other, by relying on a common resource changes to module A may impact how module B functions.

Relationship to Design by Contract

Design by Contract is another concept pioneered by Bertrand Meyer relating to the concept of having modules which act in well defined and predictable manners. This allows other modules to interact with them and get the results they expect.

Explicit interfaces is an important part of the contract, since it deals directly with interactions between modules being transparent and easy to spot. Knowing interactions between modules is essential when making a contract or guarantee for the implementing module's behavior.

External Links

Notes on application architecture - In addition to a summary of the principle of explicit interfaces, this site has information on Meyer's other principles, and some other important criteria for good application design.

Object-Oriented Software Construction at Wikipedia - For more information on the text in which the principle was introduced.

Bertrand Meyer's home page - Find other publications and research by Meyer.

Design by Contract at Wikipedia - Other aspects of Design by Contract outside of the principle of explicit interfaces.

Sources

  • Meyer, Bertrand. Object-Oriented Software Construction, 2nd edition p50. ISE Inc., Santa Barbara, CA, 1997.