“abstract” 在面向对象编程中的正确定义是什么?

huangapple go评论73阅读模式
英文:

What is the correct definition of 'abstract' in OOP?

问题

我正在尝试理解面向对象编程中的“抽象”定义。

我遇到了几个主要的定义。
它们都是有效的吗?
有一个是错误的吗?
我感到困惑。

定义1
抽象是将现实世界的对象建模为编程语言的过程
抽象并不涉及接口或抽象类。
抽象是将现实世界的对象建模到编程语言中的过程。
因此,接口和抽象类只是这一过程中使用的两种技术。
在像Java这样的面向对象编程语言中,一切都是抽象的:接口、类、字段、方法、变量等等。

抽象是其他概念依赖的基本概念:封装、继承和多态。

定义2
抽象是面向对象编程(OOP)语言的关键概念之一。其主要目标是通过隐藏不必要的细节来处理复杂性,使用户能在提供的抽象基础上实现更复杂的逻辑,而无需理解甚至考虑所有隐藏的复杂性。

英文:

I am trying to understand the definition of 'abstraction' in OOP.

I have come across a few main definitions.
Are they all valid?
Is one of them wrong?
I'm confused.

Definition 1:
Abstraction is the progress of modeling real-world objects into programming language
Abstraction is not about interfaces or abstract classes.
Abstraction is the progress of modeling real-world objects in the programming language.
Hence interfaces and abstract classes are just two techniques used in this progress.
In an Object-Oriented Programming language like Java, everything is an abstraction: interface, class, field, method, variable, etc.

Abstraction is the fundamental concept on which other concepts rely: encapsulation, inheritance, and polymorphism

Definition 2:
Abstraction is one of the key concepts of object-oriented programming (OOP) languages. Its main goal is to handle complexity by hiding unnecessary details from the user. That enables the user to implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity.

答案1

得分: 3

两个定义都是有效的。这两个定义之间的区别主要是由上下文决定的。第一个与“建模”中抽象的作用有关。第二个与“编程”中抽象的作用有关。

我的建议是不要纠结于寻找“正确”的定义。这些术语有许多不同的含义和解释。并且没有官方的仲裁者可以告诉您哪个定义是正确的。这与数学不同...

英文:

Both definitions are valid. The differences between the definitions are largely due to the context. The first is about the role of abstraction in modelling. The second is about the role of abstraction in programming.

My advice is to not get hung up on looking for the "correct" definition. These terms have a range of meanings and interpretations. And there is no official arbiter to tell you which definition is correct. This is NOT mathematics ...

答案2

得分: 1

定义1太狭隘。将“将现实世界的对象建模到编程语言中”视为抽象(尽管我更愿意在此处使用建模这个术语),但还有许多其他形式的抽象。

定义2更好。

英文:

Definition 1 is too narrow. "modeling real world objects into programming language" can be regarded as abstraction (although I would rather use the term modeling here), but there are many more forms of abstraction.

Definition 2 is better.

答案3

得分: 0

Definition 1 并没有准确地解释抽象。将现实世界对象建模到编程语言中的过程称为面向对象编程(OOP)。抽象是面向对象编程的一个概念。

Definition 2 在解释抽象方面做得更好。

但最好用你自己的思想和话语理解这个概念。

想一想英文中“抽象”一词的含义。它被定义为“处理思想而不是事件的质量”。在面向对象编程中,类似地,抽象是一个概念,其中您仅显示与用户有关的数据,并隐藏对象的不必要细节。

英文:

Definition 1 doesn't exactly explain abstraction. Process of modelling real world objects to programming languages is called OOP. Abstraction is a OOP concept.

Definition 2 does a better job at explaining abstraction.

But it's better to understand the concept in your own thoughts and words.

Think about the meaning of the word abstraction in english. It's defined as "the quality of dealing with ideas rather than events". In OOP it's similar, abstraction is a concept where you show only relevant data and conceal unnecessary details of an object from the user.

答案4

得分: -1

[Purifying]并不意味着[Abstraction],净化是继承支柱的重要规则。

[Hiding]并不意味着[Abstraction],隐藏是封装支柱的重要规则。
--------
—> 隐藏、净化、覆盖或封装永远不等于抽象 <—

第一个定义是正确的答案:
抽象是在编程语言中对现实世界对象建模的过程。
—<< 抽象 = 类 = 蓝图 = 对某些对象建模>>—
抽象是面向对象编程的第一步规则和支柱…
--------
这意味着[类和接口]…

[抽象]不仅仅是[建模]…

一般而言:

一个房屋建筑工程师在没有蓝图的情况下无法开始建造任何房屋!!

抽象 =>>(这是进入面向对象编程的第一步)以及(所有支柱中的支柱

没有抽象就没有类,没有接口,没有抽象类,自然也没有对象…
----------
=> (没有类[抽象]就没有对象[真实物体]!!)

英文:

[Purifying] is not means [Abstraction], Purifying is the important rule of Inheritance Pillar<br>

[Hiding] is not means [Abstraction], Hiding is the important rule of Encapsulation Pillar <br>
--------<br>
—> Hiding or Purifying or Covering or Encapsulating Never = Abstraction <—

The First Definition is the Correct Answer:
Abstraction is the progress of modeling real-world objects in the programming language.<br>
—<< Abstraction = Classes = Blueprints = Modelling some Objects>> —<br>
Abstraction is the first Step Rule & Pillar of OOP Pillars…<br>
--------<br>
wich means [Classes and Interfaces] …<br>

[Abstraction] is not more than a [Modelling] …<br>

in general:

A home Construction Engineer cannot start Constructing any home without a Blueprint !!

Abstraction =>> ( it’s the first Step into OOP ) and ( the Pillar of All Pillars )

without Abstraction there is no Classes no Interfaces no Abstract Classes and Automatically no Objects..<br>
----------<br>
=> (no Classes[Abstraction] no Objects[REAL THINGS] !!)

huangapple
  • 本文由 发表于 2020年10月25日 13:00:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/64520515.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定