views:

6151

answers:

7

Can you tell me what is difference between ABSTRACTION and INFORMATION HIDING in software development?

I am confused abstraction hides detail implementation and information hiding abstracts whole details of something.


updated: I found good answer for these three concepts.

From here: http://www.itmweb.com/essay550.htm

  • 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.
  • Information Hiding: Its interface or definition was chosen to reveal as little as possible about its inner workings."
    • 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.
  • Encapsulation: It refers to building a capsule, in the case a conceptual barrier, around some collection of things.
    • As a process: Encapsulation means the act of enclosing one or more items within a container.
    • As an entity: Encapsulation refers to a package or an enclosure that holds(contains, encloses) one or more items.
    • 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 not obviously not true.

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.

+4  A: 

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.'

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.

Edit: I seems to me that abstraction is the process of deciding which parts of the implementation that should be hidden.

So its not abstraction VERSUS information hiding. It's information hiding VIA abstraction.

jamting
A: 

The way I see it, abstraction is hiding details of implementation as you put it.

You abstract something to a high enough point that you'll only have to do something very simple to perform an action.

Information hiding is hiding implementation details. Programming is hard. You can have a lot of things to deal with and handle. There can be variables you want/need to keep very close track of. Hiding information ensures that no one accidentally breaks something by using a variable or method you exposed publicly.

These 2 concepts are very closely tied together in object-oriented programming.

Dan Herbert
A: 

@Dan, @jamting:

Is there no differences betwwen two concepts? Is it just lexicographic difference?


@jamting:

Information Hiding is just hiding somewhat complicated thing but abstraction is process to decide whether some part will be hidden or not. So you mean ABSTRACTION is bigger or wider concepts than INFORMATION HIDING. Right?


@jamting: I still have no clear understanding about this. How about this: It's ABSTRACTION via INFORMATION HIDING. I think this also makes sense.

popopome
A: 

See Joel's post on the Law of Leaky Abstractions

http://www.joelonsoftware.com/articles/LeakyAbstractions.html

Basically, abstracting gives you the freedom of thinking of higher level concepts. A non-programming analogy is that most of us do not know where our food comes from, or how it is produced, but the fact that we (usually) don't have to worry about it frees us up to do other things, like programming.

As for information hiding, I agree with jamting.

Jason Z
A: 

Abstraction allows you to treat a complex process as a simple process. For example, the standard "file" abstraction treats files as a contiguous array of bytes. The user/developer does not even have to think about issues of clusters and fragmentation. (Abstraction normally appears as classes or subroutines.)

Information hiding is about protecting your abstractions from malicious/incompetent users. By restricting control of some state (hard drive allocations, for example) to the original developer, huge amounts of error handling becomes redundant. If nobody else besides the file system driver can write to the hard drive, then the file system driver knows exactly what has been written to the hard drive and where. (The usual manifestation of this concept is private and protected keywords in OO languages.)

Zooba
+12  A: 

Go to the source! Grady Booch says (in Object Oriented Analysis and Design, page 49, second edition):

"Abstraction and encapsulation are complementary concepts: abstraction focuses on the observable behavior of an object... encapsulation focuses upon the implementation that gives rise to this behavior... encapsulation is most often achieved through information hiding, which is the process of hiding all of the secrets of object that do not contribute to its essential characteristics."

In other words: abstraction = the object externally; encapsulation (achieved through information hiding) = the object internally,

Example: In the .NET Framework, the System.Text.StringBuilder class provides an abstraction over a string buffer. This buffer abstraction lets you work with the buffer without regard for its implementation. Thus, you're able to append strings to the buffer without regard for how the StringBuilder internally keeps track of things such the pointer to the buffer and managing memory when the buffer gets full (which it does with encapsulation via information hiding).

rp

rp
A: 

To abstract something we need to hide the detail or to hide the detail of something we need to abstract it. But, both of them can be achieved by encapsulation.

So, information hiding is a goal, abstraction is a process, and encapsulation is a technique.

Selo