C#中的抽象是什么? [英] What is abstraction in C#?

查看:30
本文介绍了C#中的抽象是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对抽象的许多定义感到困惑.谁能告诉我什么是抽象以及我们如何实现它?

I am confused in between many definitions of abstraction. can any one tell me what is abstraction and how can we achieve it ?

推荐答案

抽象OOP理论中在于只保留特定问题的现实世界对象的相关方面.因此,我们谈论现实的抽象.这是一种减少.

Abstraction in OOP theory consists in retaining only the relevant aspects of a real world object for a specific problem. Thus we talk about abstraction of the reality. It's a reduction.

例如,在现实世界中,我们有猫和狗,它们是脊椎动物.这样的动物具有头部和腿部等特性,以及行走和进食等操作.然后我们将定义,它们将是 Animal、Cat 和 Dog.

For example, in the real world we have cats and dogs that are vertebrate animals. Such an animal has properties such as head and legs, and operations like walking and eating. We will then define classes that will be Animal and Cat and Dog.

所以我们有了继承的概念,其中猫和狗继承了共同的属性和操作,然后我们将把它们放在动物级别,而不是在子类中重复这些元素:这就是概括.此外,猫会喵喵叫,狗会吠:这就是专长.

So we have the concept of inheritence where the cat and the dog inherits properties and operations that are common and that we will then put at the level of animal to not repeat these elements in the children class: that is the generalization. Also cats can meow and dogs can bark: that is the specialization.

因此,抽象是将现实世界投射到更有限的概念世界.

进行抽象是确定我们设计计算机系统和软件所需的属性和行为我们拒绝所有不需要的.

例如,在银行系统中,我们识别具有姓名、地​​址等的客户.我们采取一切必要的措施并拒绝他人,例如他们的饮食方式或走路方式,或者他们读的最后一本书是什么.

For example, in a banking system, we identify customer that have a name, an address and so on. We take all things necessary and reject others like how they eat or how they walk or what is the last book they read.

抽象是定义所需的概念(实体及其方面、行为和关系),忘记什么是不需要的.这是现实的一部分.

Absraction is defining the needed concepts (the entities and their aspects and their behaviors and their relations) and forgot what is not needed. it's a section of reality.

我们将命名为一个来自抽象的概念,而对象则将这个概念命名为实例.将在计算机上运行的软件域,因此是物化.

We name class a concept that comes from the abstraction and object an instance of this concept within the software domain that will run on a computer that is thus a materialization.

所有其他 OOP 术语都是定义实现此目的的方法的词汇.

All others OOP terms are vocabulary to define the means to do that.

例如,封装是掩盖类中一些无法从外部访问的属性和操作的过程:这些只是内部事物和行为,如消化系统.

For example encapsulation is the process to mask some properties and operations in the class that will become inaccessible from the exterior: these are only internal things and behaviours like a digestive system.

除了之外,还有多态接口.

如何在私有和受保护的访问修饰符之间进行选择

什么是多态性

接口和类有什么区别

以下是一些维基词典的定义:

Here are some Wiktionary definitions:

抽象、分离、撤回或带走的行为;退出;被带走的状态.

The act of abstracting, separating, withdrawing, or taking away; withdrawal; the state of being taken away.

关注一个对象的一个​​特征而不是整个对象的一组特征的行为;将所述品质与对象或想法分开的行为.

The act of focusing on one characteristic of an object rather than the object as a whole group of characteristics; the act of separating said qualities from the object or ideas.

比较不同对象之间的共性并使用这些相似性进行组织的行为;概括特征的行为;所述泛化的产物.

The act of comparing commonality between distinct objects and organizing using those similarities; the act of generalizing characteristics; the product of said generalization.

(计算)为了控制工程系统(尤其是软件系统)的智能复杂性而忽略或隐藏细节以捕获不同实例之间的某种共性的任何泛化技术.

(computing) Any generalization technique that ignores or hides details to capture some kind of commonality between different instances for the purpose of controlling the intellectual complexity of engineered systems, particularly software systems.

(计算)通过抽象技术产生的任何智力结构.

(computing) Any intellectual construct produced through the technique of abstraction.

https://en.wiktionary.org/wiki/abstraction

这篇关于C#中的抽象是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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