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

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

问题描述

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

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

推荐答案

抽象 在于,仅保留现实世界中针对特定问题的物体的相关方面.因此,我们谈论现实的抽象.这是还原.

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.

例如,在现实世界中,猫和狗是脊椎动物.这种动物具有诸如头和腿的特性,以及诸如走路和进食的操作.然后,我们将定义,它们将是动物,猫和狗.

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.

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

Abstraction is thus a projection of the real world into a more limited conceptual world.

进行抽象是确定我们设计计算机系统所需的属性和行为,从而确定了软件,并且我们拒绝了所有不需要的内容.

Doing abstraction is identifying the properties and behaviors we need to design a computer system and therefore software, and we reject all that we don't need.

例如,在银行系统中,我们确定具有名称,地址等的客户.我们将所有必要的东西都拒之门外,并拒绝其他人,例如他们的饮食,步行方式或他们最近读的书是什么.

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天全站免登陆