All Topics  
Information hiding

 

   Email Print
   Bookmark   Link






 

Information hiding



 
 
Information hiding in computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
 is the principle of hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed. The protection involves providing a stable interface
Interface (computer science)

Interface generally refers to an Abstraction_%28computer_science%29 that an entity provides of itself to the outside. This separates the methods of external communication from internal operation, and allows it to be internally modified without affecting the way outside entities interact with it, as well as provide Polymorphism in object-orien...
 which shields the remainder of the program from the implementation (the details that are most likely to change).

odern programming languages, the principle of information hiding manifests itself in a number of ways, including encapsulation (given the separation of concerns
Separation of concerns

In computer science, separation of concerns is the process of breaking a computer program into distinct features that overlap in functionality as little as possible....
) and polymorphism.

The term encapsulation is often used interchangeably with information hiding.






Discussion
Ask a question about 'Information hiding'
Start a new discussion about 'Information hiding'
Answer questions from other users
Full Discussion Forum



Encyclopedia


Information hiding in computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
 is the principle of hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed. The protection involves providing a stable interface
Interface (computer science)

Interface generally refers to an Abstraction_%28computer_science%29 that an entity provides of itself to the outside. This separates the methods of external communication from internal operation, and allows it to be internally modified without affecting the way outside entities interact with it, as well as provide Polymorphism in object-orien...
 which shields the remainder of the program from the implementation (the details that are most likely to change).

Overview

In modern programming languages, the principle of information hiding manifests itself in a number of ways, including encapsulation (given the separation of concerns
Separation of concerns

In computer science, separation of concerns is the process of breaking a computer program into distinct features that overlap in functionality as little as possible....
) and polymorphism.

The term encapsulation is often used interchangeably with information hiding. Not all agree on the distinctions between the two though; one may think of information hiding as being the principle and encapsulation being the technique. A software module hides information by encapsulating the information into a module or other construct which presents an interface.

A common use of information hiding is to hide the physical storage layout for data so that if it is changed, the change is restricted to a small subset of the total program. For example, if a three-dimensional point (x,y,z) is represented in a program with three floating point
Floating point

In computing, floating point describes a system for numerical representation in which a String of digits represents a rational number.The term floating point refers to the fact that the radix point can "float": that is, it can be placed anywhere relative to the Significant figures of the number....
 scalar
Scalar (computing)

In computing, a scalar is a variable or field that can hold only one value at a time; as opposed to composite variables like array, List , object composition, etc....
 variables and later, the representation is changed to a single array
Array

In computer science, an array is a data structure consisting of a group of element s that are accessed by index . In most programming languages each element has the same data type and the array occupies a contiguous area of computer memory....
 variable of size three, a module designed with information hiding in mind would protect the remainder of the program from such a change.

In object-oriented programming
Object-oriented programming

Object-oriented programming is a programming paradigm that uses "Object_" and their interactions to design applications and computer programs....
, information hiding reduces software development risk by shifting the code's dependency on an uncertain implementation (design decision) onto a well-defined interface
Interface (computer science)

Interface generally refers to an Abstraction_%28computer_science%29 that an entity provides of itself to the outside. This separates the methods of external communication from internal operation, and allows it to be internally modified without affecting the way outside entities interact with it, as well as provide Polymorphism in object-orien...
. Clients of the interface perform operations purely through it so if the implementation changes, the clients do not have to change.

History

The concept of information hiding was first documented in a paper by David Parnas
David Parnas

David Lorge Parnas is a Canadian early pioneer of software engineering, who developed the concept of information hiding in modular programming, which is an important element of object-oriented programming today....
, "" published in the Communications of the ACM
Communications of the ACM

Communications of the ACM is the flagship monthly journal of the Association for Computing Machinery . First published in 1957, CACM is sent to all ACM members, currently numbering about 80,000....
 in December 1972. Before then, modularity was discussed in Richard Gauthier and Stephen Pont in their 1970 book titled Designing Systems Programs.

Example

Information hiding serves as an effective criterion for dividing any piece of equipment, software or hardware, into modules of functionality. For instance a car is a complex piece of equipment. In order to make the design, manufacturing, and maintenance of a car reasonable, the complex piece of equipment is divided into modules with particular interfaces hiding design decisions. By designing a car in this fashion, a car manufacturer can also offer various options while still having a vehicle which is economical to manufacture.

For instance, a car manufacturer may have a luxury version of the car as well as a standard version. The luxury version comes with a more powerful engine than the standard version. The engineer
Engineer

An engineer is a person professionally engaged in a field of engineering. Engineers are concerned with developing economical and safe solutions to practical problems, by applying mathematics and scientific knowledge while considering technical constraints....
s designing the two different car engines, one for the luxury version and one for the standard version, provide the same interface for both engines. Both engines fit into the engine bay of the car which is the same between both versions. Both engines fit the same transmission, the same engine mounts, and the same controls. The differences in the engines are that the more powerful luxury version has a larger displacement with a fuel injection system that is programmed to provide the fuel air mixture that the larger displacement engine requires.

In addition to the more powerful engine, the luxury version may also offer other options such as a better radio with CD player, more comfortable seats, a better suspension system with wider tires, and different paint colors. With all of these changes, most of the car is the same between the standard version and the luxury version. The radio with CD player is a module which replaces the standard radio, also a module, in the luxury model. The more comfortable seats are installed into the same seat mounts as the standard types of seats. Whether the seats are leather or plastic, or offer lumbar support or not, doesn't matter.

The engineers design the car by dividing the task up into pieces of work which are assigned to teams. Each team then designs their component to a particular standard or interface which allows the sub-team flexibility in the design of the component while at the same time ensuring that all of the components will fit together.

As can be seen by this example, information hiding provides flexibility. This flexibility allows a programmer to modify functionality of a computer program during normal evolution as the computer program is changed to better fit the needs of users. When a computer program is well designed decomposing the source code solution into modules using the principle of information hiding, evolutionary changes are much easier because the changes typically are local rather than global changes.

Cars provide another example of this in how they interface with drivers. They present a standard interface (pedals, wheel, shifter, signals, gauges, etc.) on which people are trained and licensed. Thus, people only have to learn to drive a car; they don't need to learn a completely different way of driving every time they drive a new model. (Granted, there are manual and automatic transmissions and other such differences, but on the whole cars maintain a unified interface.)

Relation to Object-Oriented Programming


The authors of Design Patterns discuss the tension between inheritance
Inheritance (computer science)

In object-oriented programming, inheritance is a way to form new class es using classes that have already been defined. The inheritance concept was invented in 1967 for Simula....
 and encapsulation
Encapsulation (computer science)

In computer science, Encapsulation is the hiding of the internal mechanisms and data structures of a software component behind a defined interface, in such a way that users of the component only need to know what the component does, and cannot make themselves dependent on the details of how it does it....
 at length and state that in their experience, designers overuse inheritance (Gang of Four 1995:20). The danger is stated as follows:

"Because inheritance exposes a subclass to details of its parent's implementation, it's often said that 'inheritance breaks encapsulation'". (Gang of Four 1995:19)


See also

  • Implementation inheritance
    Implementation inheritance

    In programming, Implementation inheritance is the inheritance of the full functionality of a Class , as opposed to the inheritance of an interface , which simply defines the methods that must be present....
  • Inheritance semantics
    Inheritance semantics

    Inheritance semantics is an important concept in object-oriented programming....
  • Modularity (programming)
    Modularity (programming)

    Modular programming is a software design technique that increases the extent to which software is composed from separate parts, called modules. Conceptually, modules represent a separation of concerns, and improve maintainability by enforcing logical boundaries between components....
  • Virtual inheritance
    Virtual inheritance

    In the C++ programming language, virtual inheritance is a kind of Inheritance that solves some of the problems caused by multiple inheritance by clarifying ambiguity over which ancestor class members to use....
  • Transparency (computing)
    Transparency (computing)

    Any change in a computing system, such as new feature or new component, is transparent if the system after change adheres to previous interface as much as possible while changing its internal behaviour....
  • Scope (programming)
    Scope (programming)

    In computer programming, scope is an enclosing context where values and expressions are associated. Various programming languages have various types of scopes....


External links