登陆注册
23770800000034

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

同类推荐
  • 当英语成为时尚:我与妈妈有个约会

    当英语成为时尚:我与妈妈有个约会

    有一种语言,无处不在,它被用来撰写了大多数对人类文明产生过影响的重要文献,它不仅成为全球沟通中被一致认可的明星品牌,更是当今社会深受追捧的时尚.它的名字叫英语。
  • 1368个单词就够了

    1368个单词就够了

    《1368个单词就够了》这本书是作者王乐平先生历时4年研发,在教学过程中更好的实现了本书思想的实际指导作用。这本书的基础在于:中国人背了多年的单词,学语法,练习听力和口语,参加了多种类型的考试,但由于缺乏语言环境,很多人在真正使用英语的时候,还是出现表达障碍。这个时候,很多人的反应就是背更多的单词!但,这些年你背的那些单词都用上了吗?中国人英语学习的困境在于缺乏英语思维!运用英语思维,1368个单词就够你表达所有你想要表达的内容!这本书里,王乐平老师根据实践教学和经验,逐步的讲解了在1368个单词的拓展,如何运用英语思维,实现无障碍的表达。让你的英语,张口就来!
  • 日常生活英语口语即学即用

    日常生活英语口语即学即用

    本书取材于人们日常生活的方方面面,范围广、实用性强。共分7章:日常交际、时尚生活、饮食、运动和休闲、交通工具、快乐闲谈和情绪情感。本书对具有中低层次英语水平的读者提高英语口语水平大有帮助。
  • 爱在尘埃堆积的角落

    爱在尘埃堆积的角落

    很多时候,爱就是这样简简单单的两三事。我牵着你的手,你靠着我的肩膀,刹那间,爱就是一切。过寻常日子,看细水长流。虽无声,却动人。
  • 课外英语-七彩音符寂静之声(双语版)

    课外英语-七彩音符寂静之声(双语版)

    本书收录了世界经典英文歌曲,其中包括脍炙人口的圣诞夜、往日情怀、说你,说我等,每首歌曲都有中英文歌词、语言点解析及注释赏析。
热门推荐
  • 快穿:调教男配

    快穿:调教男配

    在家打盘消消乐也能被劈死,避雷针呢?撩妹子去了?“欢迎1010号系统,您可以任性选择一个场景完成宿主愿望和系统自带任务,在完成N个任务后,即可原地复活”“你脑子瓦特了?你当这是打boss呢?你是驴妈妈就可以带我飞?”“……对不起,我是系统不是驴妈妈,您的任务也不是打boss,而是调教boss,把boss调教成一个合格的老司机。”调教老司机?这年头,连系统都这么污?我可以选择拒绝么?“友情提醒,如果您不能完成宿主愿望和系统任务,将会被系统抹杀”从此,夏子曰被迫走上了攻略各种男神,打脸白莲花绿茶婊,调教无敌老司机的爆笑之旅。对方邀请您加入,您可以选择,接受or被迫接受?
  • 小狼,放肆

    小狼,放肆

    青春的荷尔蒙在狂舞飞扬,她根本不知道蝴蝶可以缠绵,却不一定能高飞,就犹如相爱和背叛都是一座火山,火山不是死的,只要给它条件。当安琴的爱情如火山般活跃的时候,背叛却已在孕育之中,闺蜜并不浪荡,或许只是因为男人太喜新鲜……
  • 挚爱倾城妃

    挚爱倾城妃

    林中救起的那一刻,他深知自己已无药可救。琼花树下的那一眼,她情愫以生。他不知自己怎会如此爱她,只知自己像等她许久。奈何桥上的深情誓言,妖娆而肆意绽放的彼岸花。宠入骨的宠文
  • tfboys之再爱你一次

    tfboys之再爱你一次

    还记得那年的雨季吗?我们第一次见面的地方,你微笑着,那么迷人,可是……………
  • 总裁的蛊师保镖

    总裁的蛊师保镖

    “TT集团是最大的企业集团,包括26个下属公司,员工总数19.6万人,进入美国《财富》杂志2014年世界500强前五十,2014年TT集团营业额约1965亿美元。并且是当年我市电子行业营利和纳税第一。”“除此之外,幂晶手机集团、冰莹手机集团、黑杉风投基金,都是我市纳税前列的企业,在此,我代表东海市感谢这些优秀企业的贡献!”“下面请这些集团的总裁上台,市长将会亲自颁奖……”记者发布会上,一名官员激动地道,但此时,一名叼着香烟的男子闯了进来。“喂,你是谁?”“对不起,我是这些集团总裁的未婚夫!”
  • 木遁传奇

    木遁传奇

    木遁,初代火影千手柱间的血继限界,初代火影千手柱间的孙子千手镜继承了初代火影的木遁血继限界,跟随二代目火影千手扉间学习了水遁,拥有了和水神千手扉间一样的水遁能力,天赋异禀的千手镜本身拥有土遁、风遁、雷遁等查克拉属性。千手镜将身负木遁血继限界,扬名立万!
  • 风云明宫

    风云明宫

    她以太皇太后母族的身份入宫,紧接因家门之变失宠,她与明帝,结于金桂散于金桂明宫内嫔妃间的残酷争斗,野猫迷案宫湖巨妖坠轿巫蛊,皆指向于她。明帝一句顾你一生使她信以为真,却不知宫内众人就如台上戏子,只要唱完这一生,不出瑕疵落幕,就太难得太不易她终究被奸人陷害入冷宫。明帝薄情后妃浮沉,家族谋反满门抄斩,彻底崩溃的她无意间得知了帝王的秘密权谋计策,重出冷宫;旧日宿敌早已倒下,局势洗牌换血。新的劲敌比比皆是,在环敌境遇下她凭靠果毅的能力,荣极皇贵妃,终是未成沧海遗明国倾颓糜烂,政变诛帝独揽朝纲。灼华,你的路还长远,面对明帝魏煜、鲁西巴达那皇帝金格桑、鸠香公爵姬笙,自命不凡的你,终是解了那一滴眼泪的秘密。
  • 天下

    天下

    月圆之夜,蜀山之巅,一剑西来,天外飞仙!正好赶上这个月圆之夜、武林群英汇聚一堂,主角穿越过来了……异界的大门向他打开了,却显得那样唐突,当适应了这个以武为尊的世界,天下便是囊中之物了。
  • 逃亡公主的绝世爱恋

    逃亡公主的绝世爱恋

    光明大陆的公主克拉丽丝,从小因检测不到魔法能量的存在,而被称为废柴。其实在她的体内,拥有着上古魔法,因为魔法太强,所以感应不到。在订婚前的几天里,克拉丽丝为了不和王子风影订婚,几乎连夜逃亡,但最终还是没能逃离自己父母的魔爪,被自己的父母用魔法给封在了房间里。就在正式订婚的这一天里,克拉丽丝冲破封印,逃离了皇宫,并改名为熙雅。虽然这位公主改了名字,但她那大大咧咧的性格还是没变。不知道这位糊涂公主会遇到些什么呢?
  • 白帝崛起

    白帝崛起

    李善:“如果说这世上有谁能让我看得起,那么很抱歉,都没有。”