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

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

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

9.2 分阶段构建

使用组合的另一个优势是可以分别构建系统及子系统,而且更重要的是这些系统可以被独立测试和维护。

毫无疑问软件系统是相当复杂的。为了构建高质量的软件,必须遵循一种规则来取得成功,这个规则就是尽可能地保持简单。为了让大型的软件系统能够正常工作并且易于维护,必须将其分割为更小的更容易管理的单元。如何实现这一点呢?1962年发表的标题为“架构的复杂性”一文中,作者HerbertSimon作为诺贝尔奖的获得者总结了对稳定的系统的以下思考:

·稳定的复杂系统通常具有一定的层级结构,每个系统由更简单的子系统构建而成,这些子系统又由更简单的子系统构建而成。这种方式是程序化软件开发过程背后的基本的功能分解方式,所以你可能已经相当熟悉了。在面向对象设计中,组合适用于这条准则,即通过简单的对象来构造复杂的对象。

·稳定的复杂系统是可分解的。这意味着你可以识别组成系统的各个部分,以及这些部分之间的交互关系。稳定的系统中组成部分之间的交互要少于组成部分内部的交互。比如立体音响系统由更简单的器件组成,即话筒、转盘和扩音器。这种方式比集成系统更稳定,因为集成系统不容易分解。

·稳定的复杂系统往往由不同类型的子系统以不同的方式组合而成。而这些子系统通常又由几种不同类型的部件组合而成。

·可工作的复杂系统往往是从可工作的简单系统演化而来。我们往往不会从头建立新系统(即重新发明轮子),而是基于经过验证的系统来构建新系统。

在立体音响系统例子(图9.3)中,假设立体音响系统是一个整体,而不是由组件组成(即立体音响系统是一个巨大的黑盒系统)。在这种情况下,如果CD播放器坏掉了而导致系统不稳定,应该怎么办呢?你需要把整个系统送去维修。这样做不仅非常复杂和昂贵,而且你无法使用剩余的其他组件。

图9.3 一步步构建、测试和验证完整系统 ...

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