Data Abstraction
| English | Chinese | Pinyin |
|---|---|---|
| complexity | 复杂性 | fù zá xìng |
| Data abstraction | 数据抽象 | shù jù chōu xiàng |
| list | 列表 | liè biǎo |
| abstract data type | 抽象数据类型 | chōu xiàng shù jù lèi xíng |
| general | 通用 | tōng yòng |
| abstraction | 抽象 | chōu xiàng |
| modeling | 建模 | jiàn mó |
| model | 模型 | mó xíng |
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:
Grouping data under one name hides needless detail.
A ______ groups many values under one name, like all the marks of a class.
A list is the most common abstract data type.
Using a list makes code general: the same loop works for 5 or 500 values.
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.
Which are benefits of data abstraction? (Select all that apply)
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:
A model simplifies reality, keeping only the relevant detail.
With a list, adding a sixth student needs no new variable and no new print line.
Only the data changes; 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.