抽象VS信息隐藏VS封装 [英] Abstraction VS Information Hiding VS Encapsulation

查看:126
本文介绍了抽象VS信息隐藏VS封装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能告诉我在软件开发中抽象信息隐藏有什么区别吗?

Can you tell me what is the difference between abstraction and information hiding in software development?

I很困惑。抽象隐藏细节实现,
信息隐藏抽象某物的全部细节。

I am confused. Abstraction hides detail implementation and information hiding abstracts whole details of something.

更新:我发现这三个概念很好的答案。 请参阅下面的单独答案,以获取

Update: I found a good answer for these three concepts. See the separate answer below for several citations taken from there.

推荐答案

转到源代码! Grady Booch说(在面向对象的分析和设计,第49页,第二版):

Go to the source! Grady Booch says (in Object Oriented Analysis and Design, page 49, second edition):


抽象和封装是互补的概念:抽象
专注于对象的可观察行为...封装
专注于引起这种行为的实现...
封装通常是通过信息隐藏来实现的,其中
是隐藏所有不是
的对象的秘密的过程有助于其本质特征。

Abstraction and encapsulation are complementary concepts: abstraction focuses on the observable behavior of an object... encapsulation focuses upon the implementation that gives rise to this behavior... encapsulation is most often achieved through information hiding, which is the process of hiding all of the secrets of object that do not contribute to its essential characteristics.

抽象=外部对象;封装(通过信息隐藏实现)=内部对象。

In other words: abstraction = the object externally; encapsulation (achieved through information hiding) = the object internally,

示例:
在.NET Framework中, System.Text。 StringBuilder 类提供了对字符串缓冲区的抽象。这种缓冲区抽象使您可以使用缓冲区而无需考虑其实现。因此,您无需考虑 StringBuilder 内部如何跟踪缓冲区的指针以及在缓冲区满时管理内存等情况,就可以将字符串追加到缓冲区中(通过信息隐藏进行封装)。

Example: In the .NET Framework, the System.Text.StringBuilder class provides an abstraction over a string buffer. This buffer abstraction lets you work with the buffer without regard for its implementation. Thus, you're able to append strings to the buffer without regard for how the StringBuilder internally keeps track of things such the pointer to the buffer and managing memory when the buffer gets full (which it does with encapsulation via information hiding).

rp

这篇关于抽象VS信息隐藏VS封装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆