1. Difference between Abstraction, Encapsulation and Information Hiding:<br />Abstraction – in a nutshell is making visible what you want the external world to see and keeping the other details behind the wraps. Abstraction, as a process, denotes the extracting of the essential details about an item, or a group of items, while ignoring the inessential details. It hides the complexity. It is a technique by which we decide what information to hide and what to expose.<br />Information hiding - is making inaccessible certain details which would not affect other parts of the system. Just hiding it so that it is not exposed.<br />Encapsulation - is like enclosing in a capsule. That is enclosing the related operations and data related to an object into that object.If encapsulation was “the same thing as information hiding,” then one might make the argument that “everything that was encapsulated was also hidden.” This is obviously not true. For example, even though information may be encapsulated within record structures and arrays, this information is usually not hidden and is available for use. Encapsulation is just getting a set of operations and data together which belong together and putting them in a capsule.<br />Abstraction, information hiding, and encapsulation are different but related. Abstraction is a technique that helps us identify which specific information should be visible, and which information should be hidden. Encapsulation is the technique for packaging the information in such a way as to hide what should be hidden, and make visible what is intended to be visible. Encapsulation can be thought of as the implementation of the abstract class.<br />Abstraction: One point of confusion regarding abstraction is its use as both process and an entity. Abstraction, as a process, denotes the extracting of the essential details about an item, or a group of items, while ignoring the inessential details. Abstraction, as an entity, denotes a model, a view, or some other focused representation for an actual item. <br />Information Hiding: Its interface or definition was chosen to reveal as little as possible about its inner workings.quot;
<br />Why confusing: Abstraction can be used as a technique for idenfying which information should be hidden. Confusion can occur when people fail to distinguish between the hiding information, and a technique(e.g., abstraction) that is used to help identify which information is to be hidden. <br />Encapsulation: It refers to building a capsule, in the case a conceptual barrier, around some collection of things. <br />As a process: Encapsulation means the act of enclosing one or more items within a container. <br />As an entity: Encapsulation refers to a package or an enclosure that holds(contains, encloses) one or more items. <br />If encapsulation was quot;
the same thing as information hiding,quot;
then one might make the argument that quot;
everything that was encapsulated was also hidden.quot;
This is not obviously not true. <br />CONCLUSION: Abstraction, information hiding, and encapsulation are very different, but highly-related, concepts. One could argue that abstraction is a technique that help us identify which specific information should be visible, and which information should be hidden. Encapsulation is then the technique for packaging the information in such a way as to hide what should be hidden, and make visible what is intended to be visible<br />Relationship between Abstraction, Encapsulation and Information Hiding:<br />ABSTRACTION<br />quot;
A view of a problem that extracts the essential information relevant to a particular purpose and ignores the remainder of the information.quot;
<br />quot;
The essence of abstraction is to extract essential properties while omitting inessential details.quot;
<br />quot;
Abstraction is a process whereby we identify the important aspects of a phenomenon and ignore its details.quot;
<br />quot;
Abstraction is generally defined as 'the process of formulating generalised concepts by extracting common qualities from specific examples.'quot;
<br />quot;
Abstraction is the selective examination of certain aspects of a problem. The goal of abstraction is to isolate those aspects that are important for some purpose and suppress those aspects that are unimportant.quot;
<br />quot;
The meaning [of abstraction] given by the Oxford English Dictionary (OED) closest to the meaning intended here is 'The act of separating in thought'. A better definition might be 'Representing the essential features of something without including background or inessential detail.'quot;
<br />quot;
[A] simplified description, or specification, of a system that emphasizes some of the system's details or properties while suppressing others. A good abstraction is one that emphasizes details that are significant to the reader or user and suppress details that are, at least for the moment, immaterial or diversionary.quot;
<br />quot;
An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of object and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer.quot;
<br />One point of confusion regarding abstraction is its use as both a process and an entity. Abstraction, as a process, denotes the extracting of the essential details about an item, or a group of items, while ignoring the inessential details. Abstraction, as an entity, denotes a model, a view, or some other focused representation for an actual item. Abstraction is most often used as a complexity mastering technique. For example, we often hear people say such things as: quot;
just give me the highlightsquot;
or quot;
just the facts, please.quot;
What these people are asking for are abstractions. <br />We can have varying degrees of abstraction, although these quot;
degreesquot;
are more commonly referred to as quot;
levels.quot;
As we move to higher levels of abstraction, we focus on the larger and more important pieces of information (using our chosen selection criteria). Another common observation is that as we move to higher levels of abstraction, we tend to concern ourselves with progressively smaller volumes of information, and fewer overall items. As we move to lower levels of abstraction, we reveal more detail, typically encounter more individual items, and increase the volume of information with which we must deal. <br />Usually, abstraction is not defined in terms of information hiding, e.g., note the use of words such as quot;
ignorequot;
and quot;
extracting.quot;
However, we should also note the use of the words quot;
suppressquot;
and quot;
suppressingquot;
in some of the above examples. In short, you might say that abstraction dictates that some information is more important than other information, but (correctly) does not specify a specific mechanism for handling the unimportant information. <br />INFORMATION HIDING<br />quot;
The second decomposition was made using 'information hiding' ... as a criterion. The modules no longer correspond to steps in the processing. ... Every module in the second decomposition is characterized by its knowledge of a design decision which it hides from all others. Its interface or definition was chosen to reveal as little as possible about its inner workings.quot;
<br />quot;
... the purpose of hiding is to make inaccessible certain details that should not affect other parts of a system.quot;
<br />quot;
... [I]nformation hiding: a module is characterized by the information it hides from other modules, which are called its clients. The hidden information remains a secret to the client modules.quot;
<br />quot;
[Information hiding is] the principle that users of a software component (such as a class) need to know only the essential details of how to initialize and access the component, and do not need to know the details of the implementation.quot;
<br />quot;
The technique of encapsulating software design decisions in modules in such a way that the module's interfaces reveal little as possible about the module's inner workings; thus each module is a 'black box' to the other modules in the system.quot;
<br />quot;
The process of hiding all the details of an object that do not contribute to its essential characteristics; typically, the structure of an object is hidden, as well as the implementation of its methods. The terms information hiding and encapsulation are usually interchangeable.quot;
<br />quot;
The principle of information hiding is central. It says that modules are used via their specifications, not their implementations. All information about a module, whether concerning data or function, is encapsulated with it and, unless specifically declared public, hidden from other modules.quot;
<br />We can now identify some of the sources of confusion about the differences between information hiding and abstraction, i.e.: <br />- Abstraction can be (and often is) used as a technique for identifying which information should be hidden. For example, in functional abstraction we might say that it is important to be able to add items to a list, but the details of how that is accomplished are not of interest and should be hidden. Using data abstraction, we would say that a list is a place where we can store information, but how the list is actually implemented (e.g., as an array or as a series of linked locations) is unimportant and should be hidden. <br />Confusion can occur when people fail to distinguish between the hiding of information, and a technique (e.g., abstraction) that is used to help identify which information is to be hidden. <br />- Some of the definitions for abstraction can also be sources of confusion. For example, words like quot;
ignore,quot;
quot;
omit,quot;
quot;
extract,quot;
and quot;
without includingquot;
are rather passive, and would not necessarily imply the deliberate hiding of any information, e.g., quot;
the information is there, and accessible, but we just ignore it.quot;
However, words like quot;
suppressquot;
and quot;
suppressingquot;
present a somewhat different image -- quite possibly the active and deliberate hiding of information. <br />Now, let's look at the other definitions for information hiding: <br />ENCAPSULATION<br />quot;
1. to enclose in or as if in a capsulequot;
<br />quot;
The concept of encapsulation as used in an object-oriented context is not essentially different from its dictionary definition. It still refers to building a capsule, in the case a conceptual barrier, around some collection of things.quot;
<br />quot;
It is a simple, yet reasonable effective, system-building tool. It allows suppliers to present cleanly specified interfaces around the services they provide. A consumer has full visibility to the procedures offered by an object, and no visibility to its data. From a consumer's point of view, and object is a seamless capsule that offers a number of services, with no visibility as to how these services are implemented ... The technical term for this is encapsulation.quot;
<br />quot;
Encapsulation or equivalently information hiding refers to the practice of including within an object everything it needs, and furthermore doing this in such a way that no other object need ever be aware of this internal structure.quot;
<br />quot;
We say that the changeable, hidden information becomes the secret of the module; also, according to a widely used jargon, we say that such information is encapsulated within the implementation.quot;
<br />quot;
Data hiding is sometimes called encapsulation because the data and its code are put together in a package or 'capsule.'quot;
<br />quot;
Encapsulation is used as a generic term for techniques which realize data abstraction. Encapsulation therefore implies the provision of mechanisms to support both modularity and information hiding. There is therefore a one to one correspondence in this case between the technique of encapsulation and the principle of data abstraction.quot;
<br />quot;
Encapsulation (also information hiding) consists of separating the external aspects of an object which are accessible to other objects, from the internal implementation details of the object, which are hidden from other objects.quot;
<br />quot;
[E]ncapsulation -- also known as information hiding -- prevents clients from seeing its inside view, were the behavior of the abstraction is implemented.quot;
<br />Like abstraction, the word quot;
encapsulationquot;
can be used to describe either a process or an entity. As a process, encapsulation means the act of enclosing one or more items within a (physical or logical) container. Encapsulation, as an entity, refers to a package or an enclosure that holds (contains, encloses) one or more items. It is extremely important to note that nothing is said about quot;
the walls of the enclosure.quot;
Specifically, they may be quot;
transparent,quot;
quot;
translucent,quot;
or even quot;
opaque.quot;
<br />If encapsulation was quot;
the same thing as information hiding,quot;
then one might make the argument that quot;
everything that was encapsulated was also hidden.quot;
This is obviously not true. For example, even though information may be encapsulated within record structures and arrays, this information is usually not hidden (unless hidden via some other mechanism). <br />Another example of encapsulated, but not hidden, information is the (highly undesirable) quot;
block of global informationquot;
technique reminiscent of FORTRAN's common blocks. Unfortunately, it is quite easy in some object-oriented languages to create blocks of global data in the form of classes. Specifically, it is possible to create classes with nothing but constants and variables in their public interfaces, i.e., there are no operations in the interface. (For reasons why this is undesirable, see discussions of quot;
module coupling,quot;
e.g., [Myers, 1978] and [Yourdon and Constantine, 1979].) <br />It is indeed true that encapsulation mechanisms such as classes allow some information to be hidden. However, these same encapsulation mechanisms also allow some information to be visible. Some even allow varying degrees of visibility, e.g., C++'s public, protected, and private members. <br />Even arguing that encapsulation is necessary for information hiding is not as simple as one might suspect. Of course, one could very loosely define encapsulation such that any hidden information is (logically or physically) encapsulated in something. <br />Examining the cited definitions for encapsulation above, we make the following observations: <br />encapsulation. <br />- Although not as clean as it could be, the definition supplied by [Blair et al, 1991] presents an accurate view of the relationship among abstraction, information hiding, and encapsulation. <br />CONCLUSIONS<br />Abstraction, information hiding, and encapsulation are very different, but highly-related, concepts. One could argue that abstraction is a technique that helps us identify which specific information should be visible, and which information should be hidden. Encapsulation is then the technique for packaging the information in such a way as to hide what should be hidden, and make visible what is intended to be visible. <br />It is not hard to see how abstraction, information hiding, and encapsulation became confused with one another. Further, one could argue that, regardless of their quot;
dictionary definitions,quot;
these terms have evolved new meanings in the context of software engineering, e.g., in much the same way as quot;
paradigmquot;
has. (See, e.g., [Kuhn, 1962].) However, a stronger argument can be made for keeping the concepts, and thus the terms, distinct. <br /> <br />