“数据抽象”是什么意思?到底是什么意思?
数据抽象指的是什么? 请同时提供现实生活中的例子。
What does data abstraction refer to?
Please provide real life examples alongwith.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
数据抽象指的是什么? 请同时提供现实生活中的例子。
What does data abstraction refer to?
Please provide real life examples alongwith.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(16)
抽象有两个部分:
例如,如果我正在设计一个处理库存的程序,我希望能够找出系统有多少某种类型的商品库存。从接口系统的角度来看,我不在乎是否通过 SOAP 接口或打孔卡从数据库、csv 文件、远程存储库获取此信息。我只关心我可以说
widget.get_items_in_stock()
并知道它将返回一个整数。如果我后来决定以其他方式记录该数字,则设计界面的人不需要知道、关心或担心它,只要
widget
仍然具有get_items_in_stock()
方法。同样,界面不需要关心我是否子类化小部件类并添加get_square_root_of_items_in_stock()
方法。我也可以将新类的实例传递给它。因此,在此示例中,我们隐藏了如何获取数据的详细信息,并确定任何具有
get_items_in_stock()
方法的内容都是相同的实例 类(或其子类)用于某些目的。Abstraction has two parts:
For example, if I am designing a program to deal with inventory, I would like to be able to find out how many items of a certain type the system has in stock. From the perspective of the interface system, I don't care if I am getting this information from a database, a csv file, a remote repository via a SOAP interface or punch cards. I just care that I can can say
widget.get_items_in_stock()
and know that it will return an integer.If I later decide that I want to record that number in some other way, the person designing the interface doesn't need to know, care or worry about it as long as
widget
still has theget_items_in_stock()
method. Like wise, the interface doesn't need to care if I subclass the widget class and add aget_square_root_of_items_in_stock()
method. I can pass an instance of the new class to it just as well.So in this example, we've hidden the details of how the data is acquired and decided that anything with a
get_items_in_stock()
method is an instance of the same class (or a subclass thereof) for certain purposes.数据抽象是任何允许您按照人类遇到数据而不是存储在机器上的方式处理数据的设备。
在最低级别,所有原始数据类型都是抽象 - 作为程序员,我们通常不必处理位级别的数据(这就是最终存储的方式),而是处理整数、浮点数、字符等 然后,
我们在该抽象上添加层 - 也许两个整数代表一个点,或者我们和枚举来代表一年中的月份、一周中的几天等。
对于每个抽象层,我们都会移动。离机器更远,(希望)更接近人类对数据的理解。这可能会带来性能损失——点可能并不总是可以最有效地由两个整数表示。使用抽象时,开发(和维护)时间更短,从而弥补了这一点。
Data abstraction is any device that allows you to treat data as humans encounter it rather than as it is stored on machine.
At the lowest level, all primitive data types are abstractions -- as programmers, we don't usually have to deal with data at the bit level (which is how it is ultimately stored) but as integers, floating point numbers, characters, etc.
We then add layers onto that abstraction -- maybe two integers represents a
Point
, or we and enumerations to represent the months of the year, days of the week, etc.With each abstraction layer, we move further from the machine and (hopefully) closer to human understanding of the data. This can extract a performance penalty -- it may not always be the case that points can be most efficiently represented by two integers. This is compensated for by the shorter development (and maintenance) time when abstractions are used.
创建非常适合要编程的应用程序的新数据类型的技术称为数据抽象。
The technique of creating new data type that is well suited to an application to be programmed is known as data abstraction.
抽象意味着只向外界提供必要的信息并隐藏他们的背景细节......例如。在你的计算机中,你只能看到显示器、键盘和鼠标……你对内部接线一无所知,这是抽象的。
Abstraction means providing only essential information to the outside world and hiding their background details..examp. In ur Computer u can see only monitor, keyboard nd mouse..u don't know anything about internal wiring this is abstraction.
数据抽象似乎可以解释为尽可能分解数据。食物是苹果、橙子、披萨的抽象。动物是猫、牛、猪的抽象。食物对象就像这样的伪代码:
所有食物都有名称、卡路里量和重量。这很抽象。
然后,您可以创建继承的对象,这会稍微不那么抽象。
披萨现在有配料,但它继承了食物的名称、卡路里和重量。
基本上,抽象被解释为到达每个项目的最低级别并创建从它们扩展的类。它也使您的代码更可重用...如果您已经足够好地定义了食品的基类,并包含了有关它的所有抽象内容,那么任何在食品行业工作的人都可以使用您的类。
Data abstraction seems to be explained as breaking data down as far as you can get it. food would be the abstraction of apple, orange, pizza. animal would be the abstraction of cat, cow, pig. A food object would be something like this pseudo code:
all foods have a name, calorie amount, and a weight. That's pretty abstract.
You could then make objects that inherit, which would be a bit less abstract.
pizza now has toppings, but it inherits name, calories, and weight from food.
basically abstraction has been explained as getting to the lowest level of each item and making classes that extend from them. It makes your code more reusable too... If you've bade your base class of food well enough, and included everything abstract about it anyone working in the food industry could use your class.
抽象是将人体的骨架隐藏起来。皮肤可以很好地容纳它。 (看到我在那里有多抽象吗?双关语的意思。我离题了......)
如果我有一个水瓶,那么我可以通过打开盖子,扭转它直到它弹出来喝它。
但水瓶是容器。容器盛装液体,直到它们打开并且可以饮用(假设液体是可饮用的)。
然而,并非所有容器都以相同的方式打开。有些容器(例如水瓶)具有可以拧开的盖子。其他瓶子则没有盖子,比如运动瓶,里面有弯曲的吸管,可以弯下来存放,也可以弯起来喝。
但客户端不知道
ExerciseBottle
对ExerciseBottle
的open()
的实现是什么。它调用BendStraw()
,然后将straw_open
设置为 true。但ExerciseBottle 只需调用一个函数即可完成所有这些工作。客户端不必执行open()
实现中使用的多个操作。 WaterBottle 的情况与此类似。 这就是抽象:让客户端知道后端将为其完成所有工作。当使用术语“将实现与接口分离”时,就是这个意思。Abstraction is hiding the skeleton from the human body. The skin does a great way of containing it. (See how abstract I'm being there? Pun intended. I digress...)
If I have a water bottle, then I'm able to drink from it by opening the lid, twisting it until it pops off.
But water bottles are containers. Containers hold liquids until they become open and they are able to be drunk from (assuming the liquid is drinkable).
However, not all containers are opened the same way. Some containers, such as the water bottle, have lids that can be twisted off. Others don't have lids, such as exercise bottles - those contain bendy straws that can be bent down for storage or up for drinking.
But the client doesn't know what
ExerciseBottle
's implementation ofExerciseBottle
'sopen()
is. It callsBendStraw()
, which then setsstraw_open
to true. ButExerciseBottle
simply calls one function to do all of this work. The client doesn't have to perform several actions that are used in the implementation ofopen()
. The case goes similarly forWaterBottle
. And that's what abstraction is: letting the client know that the back-end will do all of the work for it. When the term "separating implementation from interface" is used, this is what is meant.是使用易于与人类交互或接触的数据细节的复杂系统,这与计算机系统(例如二进制数字系统)的存储方式不同。
Neema、Rohan 和 Upendo(程序员)回答
Is the complex system that uses data details which are easy to interact or encounter with humans, which differ from the way computer system stores such as in binary number system.
Answered by Neema, Rohan and Upendo (The programmers)
根据给定的软件开发场景限制数据属性并删除所有不相关属性的技术。这使得软件开发变得更加简单。
The technique of limiting the data attributes according to given scenario for development of software and removing all irrelevant attributes.This makes software development simpler.
让我们以现实生活中的电视为例,您可以打开和关闭电视、更改频道、调节音量以及添加扬声器、录像机和 DVD 播放器等外部组件,但您不知道它的内部细节,即不知道它如何通过空气或通过电缆接收信号,如何翻译它们,并最终将它们显示在屏幕上。
Let's take one real life example of a TV which you can turn on and off, change the channel, adjust the volume, and add external components such as speakers, VCRs, and DVD players BUT you do not know it's internal detail that is, you do not know how it receives signals over the air or through a cable, how it translates them, and finally displays them on the screen.
它是指不包括背景细节或解释而表现本质特征的行为
It refers to the act of representing essential feature without including the background detail or the explanation
很难找到日常生活中数据抽象的例子。然而,编程语言中的任何数据类型,DBMS中的表和视图,LinkedList、List、Queue、Stack等数据结构都是数据抽象。这些抽象为您提供了以特定方式访问数据的方法。
本文可以帮助您深入理解数据抽象和控制抽象。它还具有一些现实生活中的控制和数据抽象示例。
It is difficult to find day to day life example of DATA abstraction. However, any data types in programming language, tables and view in DBMS, data structures like LinkedList, List, Queue, Stack are data abstractions. These abstractions provide you the way to access the data in particular manner.
This article may help you understand data abstraction and control abstraction in depth. It also has some of the real life examples of control and data abstractions.
抽象是指表示基本特征而不包括背景细节或解释的行为。
Abstraction rrefers to the act of representing essential features without including the background detail or explanation.
简单的数据抽象只不过是向用户隐藏不必要的数据。
示例:某人只是想打电话,他只需选择或拨打号码即可。然后单击此信息的呼叫按钮。对他来说已经足够了。他不想知道连接是如何建立的,以及拨打电话或语音如何传输的过程。
Simply Data Abstraction is nothing but the hiding unnecessary datails from user.
Example:Person simply just wants to make a call, he just select or dial no. and click on call button this info. is enough for him.He dont want to know about how connection is made and whatever process behind making call or how voice is transferred.
我知道这个问题很久以前就被问过。但仍然想分享一个现实生活中的例子,这可能会帮助其他人很容易地理解抽象的概念。
I know this question was asked long time ago. But still like to share one real life example which might help others to understand concept of
abstraction
very easily.数据抽象:
它用于向用户提供必要的信息,并向用户隐藏不必要的信息。这称为数据抽象。
它将向外界隐藏您的业务逻辑。
技术示例:
Console.WriteLine();
非技术示例:电视遥控器、汽车遥控器。
更多详细信息:实时示例数据抽象
Data Abstraction:
It is used to provide the necessary information to the user and hide the unnecessary information from the user. It is called data abstraction.
It will hide your business logic from outside the world.
Technical Example:
Console.WriteLine();
Non Technical Example: TV remote, Car Remote.
More Detail: Data Abstraction with real-time example
数据隐藏涉及oops的安全特性。根据此属性,类的私有数据成员只能在类内部访问或可见,而不能在类外部访问或可见。
data hiding deals the security features of oops. according to this property private data member of a class is accessible or visual only inside the class not outside the class.