《数据结构与算法》学习之入门篇
来源:互联网 发布:网络施工系统报价清单 编辑:程序博客网 时间:2024/06/06 02:36
Abstraction can be thought of as a mechanism for suppressing irrelevant details while at the same time emphasizing relevant ones. An important benefit of abstraction is that it makes it easier for the programmer to think about the problem to be solved.
For example, procedural abstraction lets the software designer think about the actions to be performed without worrying about how those actions are implemented. Similarly, data abstraction lets the software designer think about the objects in a program and the interactions between those objects without having to worry about how those objects are implemented.
There are also many different levels of abstraction. The lower the levels of abstraction expose more of the details of an implementation whereas the higher levels hide more of the details.
Encapsulation aids the software designer by enforcing information hiding. Objects encapsulate data and the procedures for manipulating that data. In a sense, the object hides the details of the implementation from the user of that object.
There are two very real benefits from encapsulation--conceptual and physical independence. Conceptual independence results from hiding the implementation of an object from the user of that object. Consequently, the user is prevented from doing anything with an object that depends on the implementation of that object. This is desirable because it allows the implementation to be changed without requiring the modification of the user's code.
Physical independence arises from the fact that the behavior of an object is determined by the object itself. The behavior of an object is not determined by some external entity. As a result, when we perform an operation on an object, there are no unwanted side-effects.
要点理解:
这段话的意思是,面向对象程序设计的最主要的优势是抽象(abstraction)和封装(encapsulation)。抽象的好处是让程序员能够暂时忽略细节(如实现),集中精力去考虑解决问题的方法,类似于创造一个理想模型。抽象分为过程抽象和数据抽象,过程抽象比如函数接口,迭代器等,数据抽象如类型模板等。此外,抽象根据暴露实现细节的不同,又分不同层次。封装也是隐藏实现细节,它的好处是“概念独立”和“物理独立”。我的理解就是让程序更容易模块化,各个模块相互独立,这个是概念独立;而物理独立是对象的完整性,换句话说,不依赖外部输入,它是一个闭包。
- 《数据结构与算法》学习之入门篇
- 数据结构与算法学习笔记之--数据结构
- 数据结构与算法学习-哈希表入门
- 数据结构与算法导论之入门简介
- 数据结构与算法入门
- 数据结构与算法入门
- 数据结构与算法学习之链表
- 数据结构与算法学习之查找技术
- Java数据结构与算法之学习路线
- Java数据结构与算法之学习
- 数据结构与算法学习笔记——基础入门
- 数据结构与算法---学习
- 学习数据结构与算法
- 数据结构与算法学习
- 数据结构与算法学习
- 数据结构与算法学习
- 数据结构与算法学习
- 数据结构与算法学习
- Qt之导出PDF、HTML和Word(一)
- MQTT协议及拓展
- Qt之导出PDF、HTML和Word(二)
- Qt之导出PDF、HTML和Word(三)
- Qt之操作文件夹和文件
- 《数据结构与算法》学习之入门篇
- 算法分析之基本公理
- overview_How do I develop a service
- Qt布局管理之QSplitter和QuadSplit…
- Qt之信号与槽应用小结
- WPS 文档编辑 总结与备忘
- C++设计模式之动态创建
- Qt之动态换图
- 从内存和对象的角度看C++类的静态…