都是翻译惹的祸!

都是翻译惹的祸!

昨天和同事探讨java的封装,自认为对此概念比较了解,于是侃侃而谈,然而,同事却提出了另一个概念,讨论了半天,得不到答案,只好求助于internet。
经过一番折腾,终于知道了答案。
原来都是翻译惹的祸,原因如下(以think in java为例)
在原版书中,曾提到
Each object has its own memory made up of other objects. Put another way, you create a new kind of object by making a package containing existing objects. Thus, you can build complexity into a program while hiding it behind the simplicity of objects.

再看看翻译后的
每个对象都有自己的存储空间,可容纳其他对象。或者说,通过封装现有对象,可制作出新型对象。所以,尽管对象的概念非常简单,但在程序中却可达到任意高的复杂程度。

这里,封装=package
 
那么,在对象特性时,文章又这样解释道:
Access control is often referred to as implementation hiding. Wrapping data and methods within classes in combination with implementation hiding is often called encapsulation.

这里,封装=encapsulation

 

而我呢,学java时看的是英文的书籍,故一直认为"封装=encapsulation",原来如此!

Leave a Reply

Your email address will not be published. Required fields are marked *