登陆注册
17150700000034

第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 simple 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.

同类推荐
  • 日语零起点 拿起就会说

    日语零起点 拿起就会说

    学好一门外语,就是掌握一门技能。但如何才算是掌握了这门技能呢?语言是交流的工具,所以只有学有所用、能够流畅地用外语与他人进行交流,才算是学好了这门外语。
  • 澳大利亚学生文学读本(第4册)

    澳大利亚学生文学读本(第4册)

    从最简单入门的英语句式、拼写与发音开始,并且附有大量插图,通过趣味而有教育意义的故事,引发孩子们学习语言的兴趣;并向规范、美丽的文学作品过渡,让孩子们掌握语言的艺术,感受本国的人文历史。是中国学生学习英语、全面了解西方社会的很好途径。
  • 每一次相遇都是奇迹

    每一次相遇都是奇迹

    浩如烟海的宇宙中,我们既然相遇了,那这一切就是我们生命中的奇迹。用爱去珍惜这一切,让爱永驻心间,你的人生才会如鲜花般灿烂。
  • 舌尖上的英语

    舌尖上的英语

    本书由我们的资深专业外教团队,秉承只做经典英语口语理念,倾力打造最纯正、最精美、最有味道的美食英语口语。每一个对话片段,都是真实的美食英语场景,每一句话,都是经典口语句。
  • 这个词是怎么来的:英语单词起源趣谈

    这个词是怎么来的:英语单词起源趣谈

    本书集知识性、趣味性、实用性为一体,适合各层次的英语学习和热爱者。如果你是小学生或中学生,不要怕,就当故事书来读吧,词源故事一定会为你以后的单词学习铺平道路;如果你要参加诸如四、六级或雅思托福之类的英语考试的话,不要满足于词源故事,后面的词汇扩展将是你突破考试词汇的一把利剑;如果你没有考试的压力,本书也是一本不错的休闲读物。
热门推荐
  • 双雄争霸

    双雄争霸

    林家惨遭灭门,兄弟两一步步强大,都市恩怨情仇,看两兄弟演绎不同人生,最后能否重振林家。
  • 佛说苦阴经

    佛说苦阴经

    本书为公版书,为不受著作权法限制的作家、艺术家及其它人士发布的作品,供广大读者阅读交流。
  • 心灵与境界

    心灵与境界

    本书包括:“心与心理学:中国文化心理学的意义”、“以心为本:中国文化心理学的境界”、“走近荣格与走进自己,感受中国文化心理学的意义”等9讲。
  • 兰舟轻唱

    兰舟轻唱

    天界与地府举行穿越PK赛,地府胜!所以,我火星地魂穿啦!(本文女尊,不喜慎入!)
  • tfboys之永远在一起

    tfboys之永远在一起

    三小只与三个女孩的爱情故事,由于丽莉不会写虐文,基本都是甜文
  • 明朝大忽悠

    明朝大忽悠

    诸位看官,请看此君,才高八斗学富五车忠厚善良皆不沾边……正所谓,别人笑我太疯癫,我笑别人看不穿,明朝从此不再只有苦力、悲催、特务和起义,因为有了个奇葩王孝棠,他英俊潇洒机敏过人,天赋异禀(穿越福利)勇往无前,他的人生格言是,流氓不可怕,就怕流氓有文化!王孝棠,大名府魏县人也,吃喝嫖赌坑蒙拐骗也。吃出一个中原从此无饥民,喝出一个中华第一美酒林嫖出一个八大名妓赛天仙,赌出一个前程似锦如扶云坑出一个四夷臣服万国朝,蒙出一个皇权却被相权挠拐带多少妖娆美女把郎念,骗了多少江山留中华子孙。
  • 英雄无双4·沙场英雄

    英雄无双4·沙场英雄

    《英雄无双》是一个以网络游戏为背景的超现实题材的幻想小说系列,也是国内网游小说第一人施鸥继《再生勇士》之后最受欢迎的网游小说。本书是《英雄无双》系列的第四部。因为恶魔小铃铛的原因,星月工作室遭到了一群职业玩家的灭国威胁。职业玩家的实力与无情,给女孩子们上了沉重的一课,关键时刻,还是刘仁力挽狂澜。人类阵营新一轮国王任务开始,这一次场面更加恢宏,更多高手参与其中,而逐渐恢复热血的刘仁,终于不再满足于小打小闹,他要以一敌万!游戏中精彩的任务一个接一个,但游戏之余,刘仁居然还要面临一项新任务,就是与一位女硕士探讨游戏与人生……
  • 网王柯南主家教之随风飘走

    网王柯南主家教之随风飘走

    我叫莫凛霖,普普通通初中生一枚,出生在三次元,重生在二次元。别问我怎么死的,QAQ,我才不会告诉你是被砸死的!睁开眼就是家教,后来就加入了网王和柯南……
  • 中国大科学家的故事

    中国大科学家的故事

    中华民族是一个有悠久历史的文明古国,在这个漫漫的历史长河中,为了中华民族的发展和兴旺,一批批优秀人物前赴后继,不懈努力,才换来了我们今天的幸福生活。
  • 宫中姐妹

    宫中姐妹

    后宫里,姐妹的扼杀圈。如何你们曾经相知,那么是否能相惜。姐妹情,在这深深宫院中,如何走下去?