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