Information Hiding vs Encapsulation

xiaoxiao2021-03-06  14

THESE ARE Two of Most Important Concepts in Software Design.but it is a pity there are no unified

Definitions for the Two Concepts.

Thays I am Reading the code compleve2nd 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?informationHidingHiding

The Following Description is Copied from That Link:

-------------------------------------------------- -------------------------------------------------- -------------------------------

InformationHiding Is a Principle First Published by DavidParnas in His Seminal Paper

Ondecomposingsystems.

The Basic IDEA IS That if code Chunk A Doesn't Really Need To Know Something About How Cove Chunk B

(Which It Calls) Don't make it know it. Then, When That Part of B Changes, you don't have to go

Back and change A.

IT IS WIDELY Recognized as The Most Important Criterion for Judging The Quality of A Software Design, Although

Many More People Think of It Under A Different Name. The Current Phrase "IF WE Do X We Increase 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 Walls, 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.

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

转载请注明原文地址:https://www.9cbs.com/read-47027.html

New Post(0)