Information Hiding vs Encapsulation

Source: Internet
Author: User

These are two of most important concepts in software design. But it is a pity there are no uniied

Definitions for the two concepts.

These days I am reading the code complete 2nd edition by Steve mccdonell. There are wonderful

Points of these two concepts in the book. But personally I tend to enjoy the description from

Http://c2.com/cgi/wiki? Informationhiding

The following description is copied from that link:

Certificate -----------------------------------------------------------------------------------------------------------------------------------

Informationhiding is a principle first published by David parnas in his seminal paper

Ondecomposingsystems.

The basic idea is that if code chunk a doesn't really need to know something about how code chunk B

(Which it CILS) does its job, don't make it know it. Then, when that part of B changes, you don't have to go

Back and change.

It is widely recognized as the most important criterion for judging the quality of a software design, although

Faster more people think of it under a different name. The current phrase "if we do X weIncrease Coupling

Between A and B ". Increasing coupling is equivalent with breaking informationhiding.

Encapsulation, strictly speaking, means something different; it means collecting a bunch of stuff together

And putting it in one box, or capsule. The box may or may not have opaque Wils, so this may or may not

Involve information hiding. In practice a "class" will both encapsulate (ie bundle code and data together)

And hide information (namely, implementation detail), and some people get so used to doing both at once

They no longer bother to distinguish. A few pedants still care, though.

Certificate ----------------------------------------------------------------------------------------------------------------------------------------

See the following links for more discussion:

Http://www.javaworld.com/javaworld/jw-05-2001/jw-0518-encapsulation.html

Http://www.toa.com/pub/abstraction.txt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.