Skip to Content
面向对象的思考过程(原书第5版)
book

面向对象的思考过程(原书第5版)

by 马特 魏斯费尔德
August 2021
Intermediate to advanced
450 pages
4h 46m
Chinese
Pearson
Content preview from 面向对象的思考过程(原书第5版)

8.2 什么是框架

与代码重用这一概念紧密相关的另一个概念是标准化,又被称为插和拔。框架可以实现插拔机制和重用准则。有关框架的一个经典例子是桌面应用程序。我们用Office家族中的一款产品作为示例。我当前使用的文档编辑器的条状工具栏包含了很多标签选项。这些选项与我正在使用的演示文档软件和电子表格软件中的选项非常相似。事实上前两个菜单选项(主面板,插入)在三个程序中都是一样的。不仅菜单选项是类似的,其他选项(新建、打开、保存等)看起来也极为相似。条状区域下面是文档区域,这些文档包括Word文档、演示文稿和电子表格。这种统一的框架能让我们更容易使用Office家族中的软件。它也能让开发者最大化地重用代码,而且可以重用界面设计。

事实上所有的菜单项外观都很相似,这一点并不意外。实际上当使用集成开发环境进行开发时,如果使用某个具体的平台(如Microsoft Windows或Linux),平台会提供一些功能,而无须自己创建。当你在Windows环境下创建一个窗口时,你会发现在右上角自动拥有一个最大化窗口的按钮及关闭按钮。一些操作也是标准化的,当双击标题栏时,屏幕会最小化(或者最大化)。当点击右上角的关闭按钮时,应用程序会结束运行。这都是框架的一部分。图8.1是一个文字处理程序的屏幕截图。注意菜单栏和工具栏、以及其他元素都是框架的一部分。

一个文字处理程序框架通常包括了创建文档、打开文档、保存文档、剪贴文本、复制文本、粘贴文本、搜索文档等操作。开发人员想要使用该框架,必须使用预先定义好的接口来创建应用程序。这些预先定义的接口遵从框架的标准,有两个明显的优点。首先,外观能保持一致,终端用户无须学习新的框架。其次,开发人员可以重用这些编写好的并经过测试的代码(通过测试很重要)。如果能够使用一个充分测试过的窗口,就没必要新建一个。在商业环境中时间紧迫的情况下,除非绝对必要,人们并不想学习新的东西。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Node与Express开发(第2版)

Node与Express开发(第2版)

Ethan Brown
计算机科学导论:跨学科方法

计算机科学导论:跨学科方法

罗伯特 塞奇威克, 凯文 韦恩
手把手教会你linux

手把手教会你linux

桑德.范.乌格特
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉

Publisher Resources

ISBN: 9787111684527