软件工程

本类阅读TOP10

·PHP4 + MYSQL + APACHE 在 WIN 系统下的安装、配置
·Linux 入门常用命令(1)
·Linux 入门常用命令(2)
·使用 DCPROMO/FORCEREMOVAL 命令强制将 Active Directory 域控制器降级
·DirectShow学习(八): CBaseRender类及相应Pin类的源代码分析
·基于ICE方式SIP信令穿透Symmetric NAT技术研究
·Windows 2003网络负载均衡的实现
·一网打尽Win十四种系统故障解决方法
·数百种 Windows 软件的免费替代品列表
·收藏---行百里半九十

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
Information Hiding vs Encapsulation

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

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

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:

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

          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 code chunk B

(which it calls) 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 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

   




相关文章

相关软件