What does “data abstraction” exactly mean?

2019-03-12 21:55发布

What does data abstraction refer to? Please provide real life examples alongwith.

16条回答
2楼-- · 2019-03-12 22:34

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

查看更多
老娘就宠你
3楼-- · 2019-03-12 22:36

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.

查看更多
淡お忘
4楼-- · 2019-03-12 22:40

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:

class food{

 name;
 calories;
 weight;

 public eat(name);

 }

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.

class pizza inherits food{

  toppings;

  say_toppings();

}

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.

查看更多
贼婆χ
5楼-- · 2019-03-12 22:41

It refers to the act of representing essential feature without including the background detail or the explanation

查看更多
啃猪蹄的小仙女
6楼-- · 2019-03-12 22:43

Abstraction has two parts:

  • Hide details that don't matter from a certain point of view
  • Identify details that do matter from a certain point of view and consider items to be of the the same class if they possess those details.

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 the get_items_in_stock() method. Like wise, the interface doesn't need to care if I subclass the widget class and add a get_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.

查看更多
Juvenile、少年°
7楼-- · 2019-03-12 22:44

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.

查看更多
登录 后发表回答