Data Abstraction
Đã giới thiệu| English | Ý nghĩa |
|---|---|
| complexity/kəmˈpleksɪti/ | độ phức tạp |
| Data abstraction/ˈdeɪtə əbˈstrækʃn/ | Trừu tượng hóa dữ liệu |
| list/lɪst/ | Danh sách |
| abstract data type/ˈæbstrækt ˈdeɪtə taɪp/ | Kiểu dữ liệu trừu tượng |
| general/ˈdʒenərəl/ | Phổ quát |
| abstraction/əbˈstrækʃn/ | Trừu tượng hóa |
| modeling/ˈmɒdəlɪŋ/ | Xây dựng mô hình |
| model/ˈmɒdl/ | Mô hình |
Hiding detail to manage complexity
- Real programs deal with a lot of data.
- Data abstraction 数据抽象 hides detail so we can manage complexity 复杂性.
- Instead of tracking many small pieces separately, we group them under one name.
- The most common tool for this is a list 列表.
Use a list, or one variable?
A list (data abstraction) is worth it when you have many similar values; a single variable is enough for one standalone value.
Data abstraction helps a programmer by:
Độ khó 1/5 · 100 xu + một phần thưởng nhỏ cho lần hoàn thành đầu tiên trong ngày
Grouping data under one name hides needless detail.
A ______ groups many values under one name, like all the marks of a class.
Độ khó 1/5 · 100 xu + một phần thưởng nhỏ cho lần hoàn thành đầu tiên trong ngày
A list is the most common abstract data type.
Using a list makes code general: the same loop works for 5 or 500 values.
Độ khó 1/5 · 100 xu + một phần thưởng nhỏ cho lần hoàn thành đầu tiên trong ngày
The code refers to the list by name, not to each value.
Lists group many values
- A list is an abstract data type 抽象数据类型 that groups many values under one name.
- One list
scorescan hold a whole class's marks — not a separate variable per student. - Using a list makes code more general 通用: the same code works with 5 values or 500.
- It refers to the list by name, not to each value one by one.

One list replaces many separate variables; list indexes start at 1
Which are benefits of data abstraction? (Select all that apply)
Độ khó 2/5 · 140 xu + một phần thưởng nhỏ cho lần hoàn thành đầu tiên trong ngày
One clear name beats fifty separate ones on all three counts.
Why abstraction helps
- Less repetition — you write the logic once, not once per value.
- Easier changes — add a value to the list and the same code still works.
- Fewer mistakes — one clear name is easier to get right than fifty separate names.
- This naming and grouping is the heart of abstraction 抽象.
A model of a class stores names but ignores eye colour because:
Độ khó 1/5 · 100 xu + một phần thưởng nhỏ cho lần hoàn thành đầu tiên trong ngày
A model simplifies reality, keeping only the relevant detail.
With a list, adding a sixth student needs a new variable and a new print line.
Độ khó 1/5 · 100 xu + một phần thưởng nhỏ cho lần hoàn thành đầu tiên trong ngày
False. Only the data changes: the student is added to the list, and the same loop handles it.
Abstraction is modeling
- Data abstraction is a form of modeling 建模.
- A model 模型 simplifies something so we can focus on what matters.
- A list of student names models a class, ignoring details like eye colour the program never needs.
Five marks. Without abstraction: five variables mark1…mark5 and five print lines. With a list marks: one loop prints every element. If a sixth student joins, only the data changes — no new variable, no new line.
Data abstraction hides detail to manage complexity, usually with a list — an abstract data type grouping many values under one name. It makes code general (works for any size), reduces repetition and mistakes, and is a kind of modeling: keep what matters, ignore the rest.