使用示例代码进行抽象与封装 [英] Abstraction vs Encapsulation with example code

查看:91
本文介绍了使用示例代码进行抽象与封装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

任何人都可以用示例代码描述抽象与封装。



谢谢

Abhay

解决方案

1:

Quote:

抽象:简单来说意思是理解。更好地理解系统可以获得良好的解决方案。



数据抽象:数据抽象(在OOP中也称为对象抽象)纯粹是关于开发人员对于特定于给定DATA的系统。



因此可以有抽象级别来理解系统,这与开发人员不同。可以用更高的抽象级别开发更好的系统。



差异:封装是抽象的可交付成果。 Encapsulation几乎没有谈到将您的抽象分组以满足开发人员的需求。抽象解决了设计方面的问题,而封装是实现。





2: -

引用:

封装意味着我们直接隐藏数据

交互和抽象意味着

我们打扰对象可以做什么但是不要打扰

怎么办?





3: -

Quote:

封装意味着我们将代码和数据隐藏在

单个单元中以保护来自外部世界的数据。



抽象意味着我们知道对象如何使用
但是我们不知道它是如何实现的。我们可以

使用AccessSpecifiers隐藏数据。





4: -

< blockquote class =FQ>

Quote:

OOP中的数据抽象是将实现抽象给用户的概念。它仅提供功能描述,但不提供实现部分。

以抽象类或接口为例,它为用户提供了一些方法描述,但不是内部实现。





虽然OOP中的封装是隐藏或保护外部函数数据的过程。数据与在同一类中声明的函数成员严格绑定。

例如在C#中,我们可以使用属性来操作或访问在同一类中声明的私有数据,但不能这样做来自外部功能。





5: -

http://maxotek.net/blog/csharp-tutorial-lesson-5-encapsulation-abstraction-t31.html [ ^ ]



http://www.c-sharpcorner。 com / UploadFile / tusharkantagarwal / objectorientedcsharp11162005070743AM / objectorientedcsharp.aspx [ ^ ]






看看这里:

封装与抽象 [ ^ ]

http://forums.asp.net/t/1753653.aspx/1 [ ^ ]

http://stackoverflow.com/questions/24626/abstraction-vs-information-hiding-vs-encapsulation [ ^ ]

Hi All,
Can any one please describe the Abstraction vs Encapsulation with example code.

Thanks
Abhay

解决方案

1:

Quote:

Abstraction: In bare terms it means "Understanding". Better understanding of the system leads to good solution.

Data Abstraction: Data Abstraction (In OOP also known as Object Abstraction) purely talks about the understanding of the Developer about the system that is specific to the given DATA.

So there can be Levels of Abstraction to understand the system which differs from developer to developer. Better systems can be developed with higher levels of abstraction.

Difference: Encapsulation is the deliverables of Abstraction. Encapsulation barely talks about grouping up your abstraction to suit the developer needs. Abstraction solves the problem in the design side while encapsulation is the implementation.



2:-

Quote:

Encapsulation means we hide the data from directly
interaction and Abstraction means
we bother about what the object can do but don't bother
about how it does?



3:-

Quote:

Encapsulation means we are hiding the code and data in to a
single unit to protect the data from outside world.

Abstraction means we know about the object how it can be
used but we dont know how it is implemented. and we can
hide the data using the AccessSpecifiers.



4:-

Quote:

Data abstraction in OOP is the concept of abstracting the implemetaion to the user. It just gives the functional description but not the implementaion part.
Take an abstract class or an interface for example, it gives the user some method descriptions, but not the internal implementaion.


While Encapsulation in OOP is the process of hiding or securing data from outside functions. The data is strictly binded with function members declared in the same class.
For example in C# we can use properties insde the class to manipulte or access the private data declared in the same class, but cannot do so from outside functions.



5:-
http://maxotek.net/blog/csharp-tutorial-lesson-5-encapsulation-abstraction-t31.html[^]

http://www.c-sharpcorner.com/UploadFile/tusharkantagarwal/objectorientedcsharp11162005070743AM/objectorientedcsharp.aspx[^]


Hi,

Have a look here:
Encapsulation versus Abstraction[^]
http://forums.asp.net/t/1753653.aspx/1[^]
http://stackoverflow.com/questions/24626/abstraction-vs-information-hiding-vs-encapsulation[^]


这篇关于使用示例代码进行抽象与封装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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