Skip to content
Navigation Menu
Toggle navigation
Sign in
Product
Actions
Automate any workflow
Packages
Host and manage packages
Security
Find and fix vulnerabilities
Codespaces
Instant dev environments
GitHub Copilot
Write better code with AI
Code review
Manage code changes
Issues
Plan and track work
Discussions
Collaborate outside of code
Explore
All features
Documentation
GitHub Skills
Blog
Solutions
By size
Enterprise
Teams
Startups
By industry
Healthcare
Financial services
Manufacturing
By use case
CI/CD & Automation
DevOps
DevSecOps
Resources
Topics
AI
DevOps
Innersource
Open Source
Security
Software Development
Explore
Learning Pathways
White papers, Ebooks, Webinars
Customer Stories
Partners
Open Source
GitHub Sponsors
Fund open source developers
The ReadME Project
GitHub community articles
Repositories
Topics
Trending
Collections
Enterprise
Enterprise platform
AI-powered developer platform
Available add-ons
Advanced Security
Enterprise-grade security features
GitHub Copilot
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search or jump to...
Search code, repositories, users, issues, pull requests...
Search syntax tips
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Sign in
Sign up
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mdn
/
translated-content
Public
Notifications
You must be signed in to change notification settings
Fork
8k
Star
1.6k
Code
Issues
154
Pull requests
266
Actions
Projects
7
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security
Insights
Files
main
Breadcrumbs
translated-content
/
files
/
zh-tw
/
glossary
/
abstraction
/
index.md
Blame
Blame
Latest commit
History
History
42 lines (32 loc) · 1 KB
main
Breadcrumbs
translated-content
/
files
/
zh-tw
/
glossary
/
abstraction
/
index.md
Top
File metadata and controls
Preview
Code
Blame
42 lines (32 loc) · 1 KB
Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
title
:
抽象化
slug
:
Glossary/Abstraction
---
{{GlossarySidebar}}
在{{Glossary("computer programming", "電腦程式設計")}}領域中,抽象化可用來減少軟體系統複雜度、讓設計及使用效率提升,並使用簡單的 {{Glossary("API")}} 隱藏背後複雜的系統機制。
##
資料抽象化的優勢
-
避免使用者編寫低階程式碼。
-
避免程式碼重複,提升程式碼的可重用性。
-
能夠獨立地修改類別的內部��作,而不會影響使用者。
-
僅提供重要資料給使用者,得以提升應用程式或程式的安全性。
##
範例
```
js
class
ImplementAbstraction
{
//
設定內部成員的值的方法
set
(
x
,
y
) {
this
.
a
=
x;
this
.
b
=
y;
}
display
() {
console
.
log
(
`
a =
${
this
.
a
}
`
);
console
.
log
(
`
b =
${
this
.
b
}
`
);
}
}
const
obj
=
new
ImplementAbstraction
();
obj
.
set
(
10
,
20
);
obj
.
display
();
//
a = 10
//
b = 20
```
##
參見
-
維基百科上的
[
抽象化
]
(
<
https://zh.wikipedia.org/wiki/抽象化_(計算機科學)
>
)
You can’t perform that action at this time.