登陆注册
27082000000034

第34章 Software Engineering(4)

One important feature of top-down design is that at each level the detail of the design at lower levels is hidden. Only the necessary data and control that must be passed back and forth over the interfaces are defined. Furthermore, if a data structure is contained wholly within a lower level module, it need not be specified until that level be reached in the design process. However, if several modules at some level must share data, then the data structure must be chosen before progressing to a lower level. The design will include both the data structure and the means of data access for each module involved.

The bottom-up design starts with analysis of specifications of the key parts, so the feasibility of the design is tested at the early stage. If the design is not feasible under the given specifications and constraints, the requirements are changed and the design proceeds without the danger of incompatible and unrealizable specifications undiscovered until late in the design process. But in bottom-up design, each module is coded as soon as its design is fixed, in contrast with the top-down process.

It is not uncommon to have mixture of top-down and bottom-up design and coding used in a project. It is a good idea to have a top-down design and bottom-up coding, and vice versa.

The structured programming philosophy aims to provide a well-defined, well-formulated and ****** approach to program design. Structured programming requires the use of single-entry and single-exit control structures. The classical technique used to implement these principles is to restrict all control constructs to one of the three statements.

The advantages of structured programming are obvious:

(1) Clarity—structured programs generally have clarity and logical pattern to their control structure which is a tremendous advantage throughout the design process.

(2) Productivity—programmers who use structured techniques show a significant increase in instructions coded per man-hour of work. Similar advantages are claimed for the test phase.

(3) Fixed style—structured programming tends to limit the coding to a few straightforward design approaches. This aids the designer's associates and successors in understanding the design.

(4) Maintenance—the clarity and modularity of a structured design is of great help in localizing an error and redesigning the offending section of code.

(5)Redesign—most large software products are subject to occasional redesign (often called enhancement). The clarity and modularity of structured design maximize the amount of code, which can be reused.

【Vocabulary】

top-down

自顶向下

bottom-up

由底向上

decomposition

n. 分解,腐烂

process

vt. 加工,处理

module

n. 模数,模块

straightforward

adj. 正直的,坦率的,简单的

hidden

adj. 隐藏的

furthermore

adv. 此外,而且

wholly

adv. 整个,统统,全部

specification

n. 详述,规格,说明书

coding

n. 译码

vice

n. 恶习,恶行,罪恶,缺点

philosophy

n. 哲学,哲学体系,冷静

clarity

n. 清楚,透明,明确性

maintenance

n. 维护,保持,可维护性

occasional

adj. 偶然的,临时的,非经常的

modularity

n. 模块性

structure programming

结构化程序设计

【参考译文】

现代软件设计的方法

下面简单论述一下诸如自顶向下程序设计、自底向上程序设计和结构化程序设计的现代软件设计中的一些主题。

自顶向下程序设计基本上是一个重点放在程序的控制流程和控制结构的分解过程。第一步是研究手中任务的各个部分,并将其分解为几个模块(一般是3到10个)。第二步是将模块进一步细分为独立的子模块,这个过程将不断重复直到分解的模块足够小,能够透彻地理解,并能很快地以直接和简单的方式编程。由此形成一个多层逻辑或控制结构,很明显某些模块将扩展到很多层。

自顶向下程序设计的一个重要特征是对每一层而言,其下面层次的详细设计被隐藏起来,只有需要回传及超出接口的必要数据和控制被定义。此外,如果一个数据结构完全属于一个低层模块,设计过程中在到达该层之前不需要对其进行说明。然而当同一层次中的几个模块要共享数据时,在向下一层前进之前就应对数据结构做出选择。设计将包括数据结构和各个模块中涉及访问数据的方法。

自底向上的程序设计从分析关键部分的技术要求开始,因此设计的可行性在早期就被测试。在给定的技术要求和约束条件下,如果设计不可行则需求就必须更改,程序设计也不必承担后期才发现与技术要求互相矛盾或不可实现的风险。但是与自顶向下程序设计过程相比,在自底向上的程序设计中,每个模块的设计一旦确定就可以开始编程了。

在一个项目中,把自顶向下的程序设计和自底向上的程序设计或编程结合在一起是很常见的,而且把自顶向下的程序设计和自底向上的编程结合在一起是一个很不错的方法,反之亦然。

结构化程序设计的指导思想是提供一种定义明确、表达清晰而且简单的程序设计方法。结构化程序设计要求使用单入口和单出口的控制结构,用于贯彻这一要求的经典方法是限制控制结构,只能在三种经典结构中选择一种。

结构化程序设计的优越性是明显的:

(1)明确性——结构化程序通常具有明确性,控制结构合乎逻辑,这在程序设计过程中是一个相当大的优势;

(2)生产效率——使用结构化技术的程序员每人在一小时编写的代码有相当大的增加,相似的优越性在测试阶段也有所体现;

(3)固定的风格——结构化程序设计倾向于把编程限制在一些直截了当的设计方法内,这有助于设计人员的同事或接任者理解他的设计;

(4)可维护性——明确性和模块化对于定位错误和重新设计有缺陷的部分非常有帮助;

(5)重新设计——大部分大型软件产品都会经历一到两次重新设计的过程(通常叫做增强)。

【Reading Material】

Classic Testing Mistakes

When testing, you must decide how to exercise the program, and then do it. The doing is ever so much more interesting than the deciding. A tester's itch to start breaking the program is as strong as a programmer's itch to start writing code -- and it has the same effect: design work is skimped, and quality suffers. Paying more attention to running tests than to designing them is a classic mistake. A tester who is not systematic, who does not spend time laying out the possibilities in advance, will overlook special cases. They may be the same subtle ones that the programmers overlooked.

Concentration on execution also results in un-reviewed test designs. Just like programmers, testers can benefit from a second pair of eyes. Reviews of test designs needn't be as elaborate as product design reviews, but a short check of the testing approach and the resulting tests can find significant omissions at low cost.

What is a test design?

A test design should contain a description of the setup, inputs given to the product, and a description of expected results. One common mistake is being too specific about test inputs and procedures.

Suppose you're testing a banking application. Here are two possible test designs:

Design 1

Setup: initialize the balance in account 12 with $100.

Procedure:

Start the program.

Type 12 in theAccount window.

Press OK.

Click on the 'Withdraw' toolbar button.

In the popup dialog, click on the “all'” button.

Press OK.

Expect to see a confirmation popup that says "You are about to withdraw all the money from this account. Continue?"

Press OK.

Expect to see a 0 balance in the account window.

同类推荐
  • 英语PARTY——浪漫之都·法国

    英语PARTY——浪漫之都·法国

    本套书籍带你领略英语世界风景,感悟英语学习氛围,有助于英语学习。
  • 英语PARTY——诗海拾贝

    英语PARTY——诗海拾贝

    本套书籍带你领略英语世界风景,感悟英语学习氛围,有助于英语学习。
  • 黑暗的心(双语译林)

    黑暗的心(双语译林)

    《黑暗的心》是英国作家约瑟夫·康拉德德代表作,围绕海员马洛讲述的他早年在非洲刚果河流域行船时的一段经历展开故事。讲述的核心是一个叫库尔茨的白人殖民者的故事,一个矢志将“文明进步”带入野蛮的非洲的理想主义者如何堕落成贪婪的殖民者的故事。在接近库尔茨的过程中,作者借马洛之口向我们描述了一副令人感到压抑的浓墨重彩的非洲大陆腹地的图景。
  • 课外英语-律诗精选(双语版)

    课外英语-律诗精选(双语版)

    本套书共50册,分为美国各州的小知识,七彩缤纷的音符,优美好看的小散文,开心时分的短文,经典流传的寓言,超级高效的短句,实际有用的词汇等等在这些书中,备有单词解释,相关简介,或中文翻译,便于同学们更好的阅读和理解,真正进入文字的内涵当中,准确地和文字进行交流。主要介绍张九龄、王勃、岑参、李白、杜甫、王维、孟浩然、刘长卿、韦应物、韩翃等人的作品。
  • 那些激励我前行的身影

    那些激励我前行的身影

    该丛书由美国英语教师协会推荐,特点有三:幽默逗趣,文字浅显易懂,让你笑着学英文!
热门推荐
  • 狐媚

    狐媚

    许我长生不老,换你一世相伴………………………………
  • 超强仙尊在都市

    超强仙尊在都市

    吃了三年牢饭,又遭女友的背叛,心灰意冷的苏辰不慎从天桥上掉下去,意外获得修真者传承,从此逆天改命,吊打一切……
  • 萌妻驭夫套路深

    萌妻驭夫套路深

    不过出门买个夜宵,却遭遇绑架,还莫名其妙多了个软萌乖儿子?接下来就看她如何收服萌娃,智斗冰山大boss。可到最后,一个接着一个的谜团却接踵而来。她到底是季暖暖,还是……苏念慈?--情节虚构,请勿模仿
  • 逃离诡秘

    逃离诡秘

    穿越异界,疑点重重的金手指,诡异的死亡游戏,浩瀚奇幻的维度旅行……PS:投错区,天坑开局,稀烂文笔,迷离的剧情,提早上架的毒瘤——这是一本放飞自我的神书,不建议入坑。
  • 魔女化身校草在校园

    魔女化身校草在校园

    她是zero——暗夜女王。当有人提道“杨小姐,您对您的未婚夫印象最深的一件事是什么?”杨紫萱微微一笑“他曾经当着全校师生的面对帅炸天的校草表白的那件事很是让我印象深刻。”记者一听有料,两眼放光“请问那位校草是谁?冷少真的是短袖吗?”杨紫萱勾唇“我就是那位帅爆表的校草。”记者汗颜,他是不是知道了什么不得了的事情?!杨紫萱挑了挑眉,继续爆料“我以我性取向正常为由拒绝了他,他却说会亲自把我掰弯,然后我就果断让他给我找个女的来,因为我就是个女的。”记者冷汗直流,双腿打颤,他感觉自己离死不远了,被爆料的人可是鼎鼎大名的冷少啊!跺跺脚帝都都会震三震的大人物![男强女强,傲娇VS腹黑][爱撒狗粮耍帅虐渣~]
  • 吴念的人生

    吴念的人生

    吴念是一个性格孤冷的人,她婚前曾有两段刻骨铭心的恋情,或许是她算不上对方心尖上的人,亦或许是她放不下的骄傲,终因种种原因离散……直到她遇到他的现任丈夫,一个出身豪门的浪荡公子,原以为是找到了感情归宿,不曾想,却是她人生噩梦的开始……
  • 魔童降世之神级选择

    魔童降世之神级选择

    殷夫人:吒儿呀,你真是太好了!孙悟空:大哥,我们去那里玩?敖丙:哪吒是我的好哥们!李沫:我命由我不由天,自己的命运自己说了才算!
  • 最强都市魔神

    最强都市魔神

    三流大学毕业生秦逸,意外获得机缘造化,修魔也能成神,也能风流人间,屌丝逆袭女神,脚踩高富帅,看他如何畅游莺莺燕燕的花丛,创造传奇人生。
  • 三疯情事

    三疯情事

    小说讲述了一个普通的乡下女孩的爱情故事。她在小山村长大,年轻的生命像田野的风一样奔放自由。从农村来到城市,整个世界对她都是新鲜的。她热情泼辣,敢爱敢恨,在如花的年华里将会遇见怎样的爱情。
  • 平行世界的危机

    平行世界的危机

    梦境中醒来,信息碎片的残留,大众隐藏的秘密