+ All Categories
Home > Documents > SSD9-Unit3

SSD9-Unit3

Date post: 13-Nov-2014
Category:
Upload: api-3728126
View: 111 times
Download: 0 times
Share this document with a friend
Popular Tags:
73
SSD9: Software Specification, Testing, SSD9: Software Specification, Testing, and Maintenance and Maintenance
Transcript
Page 1: SSD9-Unit3

SSD9: Software Specification, Testing, and SSD9: Software Specification, Testing, and MaintenanceMaintenance

Page 2: SSD9-Unit3

Unit 3. Analysis and Specification Unit 3. Analysis and Specification

3.13.1 Structured Systems Analysis Structured Systems Analysis 3.23.2 Entity-Relationship Modeling Entity-Relationship Modeling

Assessments Assessments Exercise 2 Multiple-Choice Quiz 3

Page 3: SSD9-Unit3

specification documentspecification document

the specification document acts as a the specification document acts as a contractcontract between the client and the developer. between the client and the developer. It sets out exactly what the software product that the client is

purchasing must do. Ideally, Ideally, 应该但通常没有达到这个目标应该但通常没有达到这个目标

the client's requirements have been elicited accurately, and the specifications make explicit the behavior expected of the

software product in all the circumstances that may arise during its use.

the goal of the system analysis/specification phase the goal of the system analysis/specification phase build a model of the software product that the client requires.

Page 4: SSD9-Unit3

principles of analysis (Pressman) principles of analysis (Pressman)

The information domainThe information domain of a problem must be of a problem must be represented and understood. represented and understood.

The functionsThe functions that the software is to perform must that the software is to perform must be defined. be defined.

The behavior of the softwareThe behavior of the software (as a consequence of (as a consequence of external events) must be represented. external events) must be represented.

The modelsThe models that depict information, function, and that depict information, function, and behavior must be partitioned in a manner that behavior must be partitioned in a manner that uncovers detail in a layered (or hierarchical) uncovers detail in a layered (or hierarchical) fashion.fashion.

The analysis processThe analysis process should move from essential should move from essential information toward implementation detail.information toward implementation detail. 从基本从基本信息到实现细节 信息到实现细节

Page 5: SSD9-Unit3

principles of analysis (Pressman) principles of analysis (Pressman)

various types of specification techniquesvarious types of specification techniques that that address the above principles are introduced.address the above principles are introduced. commonly used in structured systems analysis, as opposed to

object-oriented analysis. Not all systems are object-orientedNot all systems are object-oriented, however, nor , however, nor

should all systems be designed that way. should all systems be designed that way. Some of the techniques and many of the ideas of the more

traditional structured systems analysis can still be valid for object-oriented analysis. 关键是看哪种方式更有效(成本、效率等上考虑)

Page 6: SSD9-Unit3

3.1 Structured Systems Analysis 3.1 Structured Systems Analysis

3.1.13.1.1 Informal Specifications Informal Specifications 3.1.23.1.2 Data Flow Diagrams Data Flow Diagrams 3.1.33.1.3 Process Logic Process Logic 3.1.43.1.4 Data Dictionaries Data Dictionaries 3.1.53.1.5 Input Output Specifications Input Output Specifications

Page 7: SSD9-Unit3

常见的交通标志常见的交通标志 表示禁止车辆驶入 表示禁止车辆驶入

“ 本路严禁任何车辆进入,否则……”

禁止汽车拖、挂车通行 禁止汽车拖、挂车通行 “ 本路严禁任何拖、挂车进入,否则……”

服务区预告 服务区预告 “ 前方两公里有服务器,有加油站,汽修厂,餐馆饭

庄……

Page 8: SSD9-Unit3

3.1.1  Informal Specifications3.1.1  Informal Specifications

Informal specifications(Informal specifications( 不正规的规格说明不正规的规格说明 )) are the are the leastleast formal type of specification. formal type of specification.

They are written in a natural, human language, They are written in a natural, human language, such as English or French, and do not require the such as English or French, and do not require the reader to understand any reader to understand any special notationspecial notation.(.( 专用设专用设计图表一般会有专门的符号系统计图表一般会有专门的符号系统 ) ) On the positive side, this enables the most unsophisticated of

clients to understand the content of the specifications document; 好处,人人都基本能了解

on the negative side there are several potential hazards.

Page 9: SSD9-Unit3

drawback of informal specificationsdrawback of informal specifications except for the simplest of software products, the text except for the simplest of software products, the text

becomes long, verbose(becomes long, verbose( 冗长,过细冗长,过细 ), and generally hard to ), and generally hard to read and comprehend. read and comprehend.

Typically, natural language specifications are written as a Typically, natural language specifications are written as a set of set of if-then clausesif-then clauses, , according to the following pattern: If some input or internal condition is

met, then the software will produce the corresponding output. It is It is difficult to assess whether all possible circumstances are difficult to assess whether all possible circumstances are

coveredcovered by the specifications, and, by the time the reader by the specifications, and, by the time the reader has reached the end of the document, it is hard to detect has reached the end of the document, it is hard to detect whether there are inconsistencies in the content simply whether there are inconsistencies in the content simply because there is so much content. because there is so much content. 内容太多,读者难以判断内容太多,读者难以判断内容是否有不一致的地方内容是否有不一致的地方 例如,计税软件有很多条件判断……

It is It is not easynot easy to determine what one could do when to determine what one could do when faced faced with so many rules and regulationswith so many rules and regulations, and it would be just as , and it would be just as hard to understand what the software should do! hard to understand what the software should do!

Page 10: SSD9-Unit3

risk of informal specificationsrisk of informal specifications

the language may be the language may be ambiguousambiguous, or , or vaguevague, or may , or may inaccuratelyinaccurately portray( portray( 描绘描绘 )) what the client’s initial what the client’s initial requirements were. requirements were. In a simple checkbook-balancing program and one of the clauses in the

specification reads, "When the balance in the account reaches 0, print out a big warning and refuse to process any more debits."

What does this clause actually say about negative balances? How is the client likely to react if you implement exactly what the

specification says instead of what the specification should have said about what the program was intended to do?

In general, informal specifications by themselves are neither In general, informal specifications by themselves are neither a crisp nor an accurate way of setting down the a crisp nor an accurate way of setting down the requirements for a software product. requirements for a software product.

They need to be They need to be augmented with more formal techniquesaugmented with more formal techniques. .

Page 11: SSD9-Unit3

3.1.2  Data Flow Diagrams 3.1.2  Data Flow Diagrams

Data flow diagrams (DFDs)Data flow diagrams (DFDs) a type of graphical notation for describing how data flows

into, out of, and within a system. The use of graphics as a means of specifying The use of graphics as a means of specifying

software dates back to the 1970s.software dates back to the 1970s. 生于生于 7070 年代年代………… One of the originators of data flow diagrams stated, One of the originators of data flow diagrams stated,

""Graphics should be used wherever possibleGraphics should be used wherever possible,“ why? ,“ why? because graphics suffer less from the ambiguities that arise in

descriptive text. Different graphical schemes have been proposed, Different graphical schemes have been proposed,

several of which are essentially equivalent. (several of which are essentially equivalent. ( 开发有开发有多种图示法多种图示法 ))

Page 12: SSD9-Unit3

本课程中要使用的数据流图符号本课程中要使用的数据流图符号 Schach (6th Schach (6th 中文版中文版 , p. 243), p. 243) 图图 11.111.1 中数据存储符中数据存储符

号有误号有误

Page 13: SSD9-Unit3

data flow diagramdata flow diagram Opposed to the Opposed to the control flowcontrol flow or or process logic, Itprocess logic, It portrays the portrays the

logical data flow, displays how logical data flow, displays how information or data enters and exits the system, it is passed from component to component.

Note that the word “system” does Note that the word “system” does not necessarily imply a not necessarily imply a software systemsoftware system — one can just as easily use data flow — one can just as easily use data flow diagrams to describe a hardware system or an diagrams to describe a hardware system or an organizational system in which people or departments are organizational system in which people or departments are the components. the components. 可以描述硬件或人的组织活动可以描述硬件或人的组织活动

In fact, a data flow diagram In fact, a data flow diagram does not make any commitmentdoes not make any commitment regarding the implementation of the system or any of its regarding the implementation of the system or any of its components. components. 不保证与不保证与 DFTDFT 一致的实现,它只表示一种逻一致的实现,它只表示一种逻辑联系辑联系

The ability to "The ability to "differentiate between the logical and the differentiate between the logical and the physicalphysical" is a feature of data flow diagrams, as well as other " is a feature of data flow diagrams, as well as other graphical representations used in specifying systems.graphical representations used in specifying systems.

Page 14: SSD9-Unit3

Pressman has said……Pressman has said……

“ “ software design proceeds like an architect's design software design proceeds like an architect's design for a building. ”for a building. ” It starts by expressing the totality of what is to be built. Then the details of each piece are gradually filled in

e.g. details of dimensions materials lighting.

Similarly software design Similarly software design moves from the essential to the more detailed. 从基本要点

到细节

Page 15: SSD9-Unit3

The The gradual elaboration of details(gradual elaboration of details( 逐步求精法逐步求精法 )) of DFDs. of DFDs.

A level 0 DFD (termed a fundamental system model A level 0 DFD (termed a fundamental system model or a context modelor a context model) ) just shows the just shows the entire software entire software productproduct as a process as a process, with input and output flowing , with input and output flowing into and out of it. into and out of it.

E.g.,E.g., a translation system that translated English a translation system that translated English input (text or speech) into Frenchinput (text or speech) into French the level 0 DFD

Page 16: SSD9-Unit3

partitioning the system a little morepartitioning the system a little more

partitioning the system a little more and showing an partitioning the system a little more and showing an additional amount of detail additional amount of detail

Page 17: SSD9-Unit3

A further refinementA further refinement

A further refinement of the level 1 DFD might show more A further refinement of the level 1 DFD might show more detail about the interpretation process, by detail about the interpretation process, by highlighting highlighting additional data sources and an intermediate stepadditional data sources and an intermediate step in the in the processing of input.processing of input.

more substantially refinement is possible, although you will more substantially refinement is possible, although you will need at some point to start making some assumptions about need at some point to start making some assumptions about the actual implementation of the system. the actual implementation of the system.

Page 18: SSD9-Unit3

significant advantage of data flowsignificant advantage of data flow

They can be They can be incrementally refinedincrementally refined to show the workings of a to show the workings of a system in more and more detail. system in more and more detail.

For large systems, the additional detail can give rise to For large systems, the additional detail can give rise to extensive and very complex diagrams, but even extensive and very complex diagrams, but even large large diagramsdiagrams will be clearer and easier to read than will be clearer and easier to read than large large informal specificationsinformal specifications. . 图形表示比文字说明更直观易于理图形表示比文字说明更直观易于理解解

The levels of refinement shown in the diagrams above are an The levels of refinement shown in the diagrams above are an example of example of in-placein-place refinementrefinement. (. ( 适当精化适当精化 ))

In addition, data flow diagrams can show In addition, data flow diagrams can show hierarchical hierarchical refinementrefinement, with more general diagrams containing , with more general diagrams containing placeholdersplaceholders(( 占位符占位符 )) for complex processes that are then for complex processes that are then expanded to expanded to show greater detail in a separate data flow show greater detail in a separate data flow diagramdiagram. (demo, next page). (demo, next page)

Page 19: SSD9-Unit3

show greater detail in a separate data flow diagramshow greater detail in a separate data flow diagram

E.g.,E.g., the level 2 DFD could have been expanded the level 2 DFD could have been expanded hierarchically as shown in the following diagram.hierarchically as shown in the following diagram.

Page 20: SSD9-Unit3

Questions?Questions?

When do you stop refining a DFD? When do you stop refining a DFD? When you cannot decompose into subprocesses any When you cannot decompose into subprocesses any

further further without entering into algorithm designwithout entering into algorithm design. .

Page 21: SSD9-Unit3

3.1.3  Process Logic3.1.3  Process Logic

Decision TreesDecision Trees Processing Specifications (Processing Specifications (PSPECsPSPECs)) Control Flow Diagrams (Control Flow Diagrams (CFDsCFDs

) for Real-Time Systems) for Real-Time Systems Control Specifications (Control Specifications (CSPECsCSPECs)) Data Flow vs. Control Flow Data Flow vs. Control Flow

Page 22: SSD9-Unit3

Process logicProcess logic

While a While a dataflow diagramdataflow diagram shows the input and shows the input and output for each conceptual component of a system, output for each conceptual component of a system, it it does not specify the process logic of the systemdoes not specify the process logic of the system. .

Process logic is Process logic is how control flows within and between each of the

component processes of the system.

Page 23: SSD9-Unit3

At this point ……At this point ……

the the actual architecturalactual architectural and and detailed design of the detailed design of the softwaresoftware has not yet been created has not yet been created

the control information in the data flow diagram the control information in the data flow diagram does not refer to specific conditional branching and looping

inside individual processes, refer to how different input or input states cause other

processes to be activated.

Page 24: SSD9-Unit3

Decision TreesDecision Trees

Different specifications of process logic are Different specifications of process logic are appropriate for different types of software products. appropriate for different types of software products. 有很多种描述处理逻辑的方法有很多种描述处理逻辑的方法

Some types of software compute output via Some types of software compute output via a multi-a multi-step decisionstep decision based onbased on different features of their different features of their inputinput. .

Therefore, the process logic can be depicted using a Therefore, the process logic can be depicted using a decision treedecision tree. .

ExamplesExamples

Page 25: SSD9-Unit3

Example of Decision TreesExample of Decision Trees

Page 26: SSD9-Unit3

Example of Decision TreesExample of Decision Trees

Page 27: SSD9-Unit3

ExampleExample

a software product used by a a software product used by a parcel delivery service parcel delivery service companycompany.. determine fees for shipping parcels based on the sizes of the

parcels, the destinations, and the delivery times. The specification for the product would need to The specification for the product would need to

include at least the following include at least the following variablesvariables:: Parcel dimensions and/or weight Origin and destination of the parcel Time constraints for delivery (which will determine the

means of transport) Extra insurance Special handling requirements

Page 28: SSD9-Unit3

a decision tree can be applied to specify the control a decision tree can be applied to specify the control flowflow

E.g., previous translation system(E.g., previous translation system( 前面翻译系统的例子前面翻译系统的例子 )) The interpreter process could detect different styles of The interpreter process could detect different styles of

documents upon input and utilize documents upon input and utilize different subprocesses or different subprocesses or templatestemplates for translation. for translation. 不同风格的文档选取,不同的翻不同风格的文档选取,不同的翻译模板,译模板,

The The translation templatestranslation templates are chosen based on the selected are chosen based on the selected output language. output language. the same basic processes for translating words and grammatical

structures might be used as a common resource for all documents; an incoming letter-type document would activate the letter-translation

template, 书信风格 an incoming journal-article-type document would activate the journal-

article-translation template. 杂志风格

Page 29: SSD9-Unit3

决策树可以描述所有的处理逻辑吗?决策树可以描述所有的处理逻辑吗? A decision tree is a A decision tree is a useful tool foruseful tool for specifying this specifying this

kind of kind of once-only once-only decision proceduredecision procedure, it helps the , it helps the reader realize reader realize whether all possible combinations of input have been

considered 穷尽所有可能的情形了吗? whether the process logic specification is complete or not.

Other kinds of systems, however, require a different Other kinds of systems, however, require a different type of specification. type of specification.

Page 30: SSD9-Unit3

Processing Specifications (PSPECs)Processing Specifications (PSPECs)

Processing specificationProcessing specification or or process specification process specification (PSPEC) (PSPEC) specifying how control flows between

components of the software product based on data (input and input states).

The PSPEC serves as a guide for design of the The PSPEC serves as a guide for design of the program component that will implement the program component that will implement the process. process. 用来指明如何实现处理过程用来指明如何实现处理过程

It is It is attachedattached to processes in a to processes in a data flow diagramdata flow diagram of the appropriate level. of the appropriate level. It describes the logic of the process from input to

output.

Page 31: SSD9-Unit3

The contents of the PSPEC can consist ofThe contents of the PSPEC can consist of

narrative textnarrative text mathematical equationsmathematical equations tablestables charts charts diagrams diagrams description in a program design languagedescription in a program design language (PDL)(PDL)..

Page 32: SSD9-Unit3

A sample A sample The PSPEC written in a PDLThe PSPEC written in a PDL

assume a component process that read a 2D assume a component process that read a 2D geometrical figure and counted sides of it.geometrical figure and counted sides of it.

Page 33: SSD9-Unit3

Control Flow Diagrams (CFDs) for Real-Time SystemsControl Flow Diagrams (CFDs) for Real-Time Systems

Real-time systemsReal-time systems monitor input continuously or semi-continuously, iterate through different internal states of the system based on the

input received from the environment and other components of the system.

In order to specify how real-time systems process their In order to specify how real-time systems process their input, input, the notation of data flow diagramsthe notation of data flow diagrams must be must be augmented to show explicitlyaugmented to show explicitly control flow control processing

Normally, a CFD is created by Normally, a CFD is created by stripping the data flow arrows off a data flow diagram and adding the control information.

Page 34: SSD9-Unit3
Page 35: SSD9-Unit3

Note for CFDNote for CFD

Control flow for copy machine software is Control flow for copy machine software is superimposed ontosuperimposed onto 叠加叠加 the DFD for clarity.the DFD for clarity. 拿掉拿掉粗竖线,它是什么?粗竖线,它是什么?

Solid linesSolid lines are used for are used for data flowdata flow and dashed lines and dashed lines for control flow. for control flow.

vertical barsvertical bars indicate the presence of a control specification (CSPEC) control flows or event flows are shown flowing into and

out of a CSPEC. AllAll CSPEC bars in a control flow diagram CSPEC bars in a control flow diagram refer torefer to

the same CSPECthe same CSPEC..

Page 36: SSD9-Unit3

A CSPEC's contentsA CSPEC's contents

similar to a PSPEC's contents with regard to show similar to a PSPEC's contents with regard to show how the input is to be processed. E.g.,

the CSPEC for events start/stop, jammed, or empty would sound an alarm.

The events jammed and empty would also invoke the process perform problem diagnosis.

A A control eventcontrol event can also be input directly into a can also be input directly into a process process without going through a CSPECwithout going through a CSPEC, , 不必经过不必经过控制规格说明控制规格说明 E.g., the repro fault ( 复印出错 ) event flows. 上边的箭头

虚线 This type of flow does not activate the process but rather provides control information for the process

algorithm.

Page 37: SSD9-Unit3

Control Specifications (CSPECs) Control Specifications (CSPECs)

represents the behavior of the product in two represents the behavior of the product in two different ways. different ways.

One kind of control specification is the One kind of control specification is the state state transition diagramtransition diagram (STD) (STD) 状态转换图状态转换图 a sequential specification that describes how previous states

and different input cause control to move through the system.

Page 38: SSD9-Unit3

A state transition diagram for the copierA state transition diagram for the copier

Page 39: SSD9-Unit3

notenote

States in the STD States in the STD do notdo not necessarily correspond necessarily correspond exactly to processes in a DFD or CFD. exactly to processes in a DFD or CFD. E.g.E.g., ,

the state making copies would encompass both manage copying and perform problem diagnosis in the CFD.

The diagram shows that two events cause a transition out of the state making copies: 1. The event copies done changes the state to reading

commands, by invoking the process read operator input.

2. The event jammed transitions the copier to diagnosing problems by activating the process perform problem diagnosis.

Page 40: SSD9-Unit3

例:保险箱的状态转换图例:保险箱的状态转换图

Page 41: SSD9-Unit3

STD is useful for detecting any omissions in the specified STD is useful for detecting any omissions in the specified behaviorbehavior

E.g.E.g.,, there is an omission ( 省略 ) in the diagram above— the

event empty should transition the copier to state reloading paper by invoking the process reload paper.

Page 42: SSD9-Unit3

state transition table(state transition table( 状态转换表状态转换表 ))

The information in an STD can also be represented The information in an STD can also be represented in a tabular format called the in a tabular format called the state transition tablestate transition table. .

Page 43: SSD9-Unit3

电梯状态图电梯状态图

Page 44: SSD9-Unit3

Data Flow vs. Control FlowData Flow vs. Control Flow

Page 45: SSD9-Unit3

Data Flow vs. Control FlowData Flow vs. Control Flow

The process model is connected to the control model The process model is connected to the control model through data conditionsthrough data conditions A data condition occurs whenever data input to a process results in a control output.

有数据输入,控制开始 E.g., while coping 20 copies of a document, reads a jammed

paper feed status( 数据输入 ) and sounds an alarm( 控制报警 ).

The control model is connected to the process model The control model is connected to the process model through through process activatorsprocess activators. . 进程启动者进程启动者 E.g., a control flow to the process perform problem diagnosis

will activate processing of fault data.

Page 46: SSD9-Unit3

3.1.4 Data Dictionaries3.1.4 Data Dictionaries

describe the kinds of data that are defined and must describe the kinds of data that are defined and must be processed within the product. be processed within the product. 系统中的各类数据系统中的各类数据

The data dictionary acts as a The data dictionary acts as a semi-formal grammarsemi-formal grammar for defining the format of the data objects identified for defining the format of the data objects identified during data flow analysis.during data flow analysis.

Page 47: SSD9-Unit3

Example for a calculator programExample for a calculator program

总是需要数据字典?除非总是需要数据字典?除非………… If the input data is very simple (if it contains very few items with little

internal structure) and the processing undergone by the data is straightforward

You can just list the operations and the numeric input. You can just list the operations and the numeric input. E.g., processes the following kind of information, a data dictionary is

unnecessary: Numbers: 0, positive and negative real and integer numbers Operations:

+ = addition, - = subtraction, * = multiplication, / = division, etc.

Page 48: SSD9-Unit3

When perform more elaborate data processingWhen perform more elaborate data processing

In such systems, a data dictionary is a very useful In such systems, a data dictionary is a very useful tool for tool for organizing information about the data and organizing information about the data and its useits use in the software product. in the software product.

Page 49: SSD9-Unit3

Example of an automatic machine translation (AMT) system Example of an automatic machine translation (AMT) system

a database product used in that translates text from a database product used in that translates text from English (source) to several other languages (target). English (source) to several other languages (target).

If word strings such as “sleep” were the If word strings such as “sleep” were the only inputonly input the system needed, the system needed, not neednot need a data dictionary a data dictionary 当然当然不可能了不可能了

Page 50: SSD9-Unit3

恼人的“恼人的“ drink”……drink”……

the word "drink" in English has two very different the word "drink" in English has two very different meanings:meanings: drink, the noun, which is the thing you drink (a coke, coffee,

water) drink, the verb, which is the action of drinking

Although in English there are many words for Although in English there are many words for which the which the exact same stringexact same string of charactersof characters is used for is used for nouns and verbsnouns and verbs, in most other languages the , in most other languages the noun noun and the verb use different strings of charactersand the verb use different strings of characters. . in Spanish:

drink (NOUN) = bebida drink (VERB) = beber

Page 51: SSD9-Unit3

exampleexample

How to do ? How to do ? input words will at least need to include the part of speech

(NOUN, VERB, etc.) in addition to a string of characters . “drink” 加上词性便于系统处理

In addition, the idea of "drink" (NOUN) and "drinking" (VERB) will not always appear exactly as "drink" in the input text.

Page 52: SSD9-Unit3

还有这种情况还有这种情况…………

Drinks Drinks Sometimes meaning more than one drink, the plural noun, at other times meaning "he or she drinks," the third person

singular verb. In English, In English,

the plural of nouns and conjugation of verbs is often regular, nouns with irregular plurals (e.g., "child" becomes

"children") verbs with irregular conjugations (e.g., "be" becomes "am,"

"are," "is"). the verb "drink" has an irregular past ("drank" the verb "drink" has an irregular past ("drank"

instead of "drinked"). instead of "drinked").

Page 53: SSD9-Unit3

exampleexample

How to do?How to do? In order to understand a variety of words used in different

ways, the AMT system will need to represent these irregularities and be able to process them.

Just to Just to account for the type of variation in inputaccount for the type of variation in input described above, described above,

a lot more information will be needed to represent a a lot more information will be needed to represent a word than just a string. word than just a string. 所有形式都要表示而不是所有形式都要表示而不是仅仅是单词本身!仅仅是单词本身!

Therefore, for Therefore, for each termeach term in the English vocabulary in the English vocabulary that the AMT is that the AMT is expected to processexpected to process, at least the , at least the data will be required (next page)data will be required (next page)

Page 54: SSD9-Unit3

for each term in the English vocabularyfor each term in the English vocabulary

Data Item Name Data Type Cardinality 基数 Modality ( 形式 )

Word String Single-valued Mandatory

Part-of-speech NOUN, VERB, ADJ

Single-valued Mandatory

Plural (for NOUN) String Single-valued Optional (if regular)

3rd person singular (VERB)

String Single-valued Optional (if regular)

Past (for VERB) String Single-valued Optional (if regular)

Transitivity (for VERB) 及物 /不及物

TRANS, INTRANS Multi-valued Mandatory

Page 55: SSD9-Unit3

The table tell us ……The table tell us ……

the type of information that you might want to put in a data the type of information that you might want to put in a data dictionary for each data item. dictionary for each data item.

In addition to the name of the In addition to the name of the data itemdata item, you will want to , you will want to specify:specify: The type of the data Its cardinality( 多样性 ), whether it can have one or more values.

a verb is transitive (“sit"), intransitive (“seat"), used both ways ("move").

Its modality( 形态 ) whether a value is mandatory (modality 1) or optional (modality 0). ( 词语形态上的变化 )

you may omit regular plurals for nouns and regular past tenses for verbs in order to save space and because it is easy to generate them

“add" by adding either an "s" or an "ed" to the noun or the verb respectively.

Page 56: SSD9-Unit3

different types different types different types of items different types of items

E.g,E.g, in a large software product, the data dictionary may in a large software product, the data dictionary may contain contain

the names of all the variables, with their types and locations, and the names of all the procedures, their types, locations, and parameters.

Depending on the application, other information in the data Depending on the application, other information in the data dictionary might include. dictionary might include. e.g.e.g.,, aliases (different names for the same item); 别名,数据表列的别名 preset values, if any; 预置值,如 枚举,常量 a content description, possibly in a formal language; and manner of use (where and how the item is used, whether as input or

output, in which process). 使用方式 Depending on the development environment, some of this Depending on the development environment, some of this

information may be information may be gathered automaticallygathered automatically..

Page 57: SSD9-Unit3

a machine-readable data dictionarya machine-readable data dictionary

While a data dictionary While a data dictionary written in a human-readable formatwritten in a human-readable format is already a very useful input to the design phase, a data is already a very useful input to the design phase, a data dictionary is dictionary is most valuable when it is also machine readablemost valuable when it is also machine readable, , and data dictionaries are usually implemented within a and data dictionaries are usually implemented within a Computer-Assisted Software Engineering (CASE) tool. Computer-Assisted Software Engineering (CASE) tool.

Other software can use Other software can use a machine-readable data dictionarya machine-readable data dictionary to check consistency between the design/implementation and to check consistency between the design/implementation and the specification, to the specification, to 机器可读,就可以利用许多工具了机器可读,就可以利用许多工具了 print out a report on the data, check for duplicate names of data and functional objects, or determine display requirements for on-screen display of the data.

The information in a data dictionary can also be used to The information in a data dictionary can also be used to create an create an entity-relationship modelentity-relationship model for object-oriented for object-oriented systems and databases.systems and databases.

Page 58: SSD9-Unit3

3.1.5  Input Output Specifications3.1.5  Input Output Specifications

define define what input a software product must acceptwhat input a software product must accept and and what corresponding output are expectedwhat corresponding output are expected. .

This is easier to specify for some products than for This is easier to specify for some products than for others. others.

E.g.,E.g.,the calculator example, the input and output the calculator example, the input and output specifications need to contain :specifications need to contain : INPUT:

Operator: multiplication (*)Multiplicands: n1, n2, n3, ... OUTPUT:n1 * n2 * n3 * ...

Page 59: SSD9-Unit3

when the input is more complexwhen the input is more complex

when the product uses a forms interface to a when the product uses a forms interface to a database, the input is more complex — database, the input is more complex —

many fields in the form may be changed at once and there may not be any visible output.

The values typed in by the user may be placed in a The values typed in by the user may be placed in a temporary memory store, and permanent output, temporary memory store, and permanent output, like changes in the database itself, may be delayed like changes in the database itself, may be delayed until the user submits the entire form. until the user submits the entire form.

Page 60: SSD9-Unit3

exampleexample

The input output specifications The input output specifications only need to only need to describe the final effects of the input on the describe the final effects of the input on the databasedatabase, but , but the submit action will also be part of the submit action will also be part of the inputthe input. . In contrast, if the user fills in a form and then cancels instead

of submitting the input, the combination of field values and cancel action will give a different output—no changes to the database.

Demo ( Demo ( 网页表单提交网页表单提交 ))

Page 61: SSD9-Unit3

Example of automatic machine translation system (AMT). Example of automatic machine translation system (AMT).

the system will be expected to translate whole sentences. the system will be expected to translate whole sentences. Since each language (and even type of document) has its Since each language (and even type of document) has its

own style of conveying the same basic contentown style of conveying the same basic content, you cannot , you cannot always expect sentences to be translated literally. always expect sentences to be translated literally.

So, while English may use a rather personal and direct style So, while English may use a rather personal and direct style to give commands in a manual, French may prefer a more to give commands in a manual, French may prefer a more indirect indirect renditionrendition of the same idea. of the same idea. 英语表达针对人且直接,英语表达针对人且直接,法语有不同的形式!法语有不同的形式!

The input output specifications would contain statements The input output specifications would contain statements like the following:like the following: English commands using the pronoun “you” will be translated in French using the

impersonal pronoun( 无 [ 非 ] 人称代词 )construction "on." For example,ENGLISH INPUT: "You must put the lever in position 'on.'"FRENCH OUTPUT:"On doit mettre le levier sur la position 'activé.'"(Roughly equivalent to "One must put the lever in position 'activated.'")

Page 62: SSD9-Unit3

The specification document should address both The specification document should address both legal and illegal input.legal and illegal input.

In the case of an illegal input the product In the case of an illegal input the product should avoid should avoid crashing if possiblecrashing if possible. . division by zero in a calculator program 找不到指定文件……

Instead, the specification Instead, the specification should describe the error-should describe the error-reporting behavior of the productreporting behavior of the product. .

Illegal inputIllegal input is preferably is preferably detected before processingdetected before processing, so it , so it can be reported to be unacceptable in a graceful manner. can be reported to be unacceptable in a graceful manner. E.g.,E.g., INPUT:

Operator: division ( / )Dividend: n1Divisor: 0OUTPUT:ERROR: Illegal division by zero

Page 63: SSD9-Unit3

software-generated errors will be given as outputsoftware-generated errors will be given as output

If illegal input cannot always be detected, then If illegal input cannot always be detected, then other types of other types of software-generated errorssoftware-generated errors will be given as output. will be given as output.

Preferably Preferably cryptic system errorscryptic system errors ( ( 系统错误系统错误 ) are translated ) are translated into into language the user can understandlanguage the user can understand to provide some to provide some information for diagnosing the source of the error. information for diagnosing the source of the error. 满足界满足界面设计的基本要求面设计的基本要求

the input output specifications should be the input output specifications should be precise, unambiguous, complete, and consistent.

This will make it easier This will make it easier to trace the design document back to the specification document verify the design.

Page 64: SSD9-Unit3

3.2 Entity-Relationship Modeling3.2 Entity-Relationship Modeling

Entity-relationship (ER) modelingEntity-relationship (ER) modeling is a formal is a formal technique that is technique that is oriented to specifying dataoriented to specifying data as as opposed to control information. opposed to control information.

ER modeling was used extensively, as far back as ER modeling was used extensively, as far back as the 1970s, for specifying databasesthe 1970s, for specifying databases

It has more recently been adopted in It has more recently been adopted in object-oriented object-oriented analysisanalysis..

Page 65: SSD9-Unit3

entity-relationship diagramentity-relationship diagram (ERD)(ERD)

Entity-relationship modeling is usually expressed Entity-relationship modeling is usually expressed graphically, through angraphically, through an entity-relationship diagramentity-relationship diagram (ERD). (ERD).

An entity-relationship diagram is a model of objects An entity-relationship diagram is a model of objects and their relationships in the worldand their relationships in the world

NotNot imply a commitment to a specific imply a commitment to a specific implementation. implementation. 不要求有某种特定实现!有多种不要求有某种特定实现!有多种方式可以实现这个模型方式可以实现这个模型 ,, 如如 relational database an object-oriented system

Page 66: SSD9-Unit3

two types of components: entities and relationshipstwo types of components: entities and relationships

EntitiesEntities represent sets of distinguishable objects in represent sets of distinguishable objects in the world.the world. In the airline database example below, the entities are

Passenger, Departure, and Flight. A A relationshiprelationship between two entities describes the between two entities describes the

way in which they are associated. way in which they are associated. The relationship between Passenger and Departure is that

each passenger is booked on one or more departures. Similarly, the relationship between Departure and Flight is

that a departure is a specific instance of a flight on a given date.

Page 67: SSD9-Unit3

The concept of The concept of cardinalitycardinality extends to relationships extends to relationships

In the partial entity-relationship diagram shown below for In the partial entity-relationship diagram shown below for an airline databasean airline database the relationship (Departure, Flight) cardinality( 基数 ) many-to-one

since each departure is an instance of a single flight but each flight can have many departures.

inverse: the relationship (Flight, Departure) cardinality: one-to-many. the relationship ( Passenger, Departure) cardinality many-to-many

because passengers may have more than one booking—one for each leg of a round trip or for different trips

each departure will have one or more passengers.

If you added the entities Airline and RouteIf you added the entities Airline and Route the relationship (Airline, Route) : many-to-many because several airlines would have flights between San Francisco and

New York and each airline would have several routes.

Page 68: SSD9-Unit3
Page 69: SSD9-Unit3

The cardinality The cardinality one-to-oneone-to-one

a company where a company where a managera manager manages manages a single a single departmentdepartment and each department has only one and each department has only one managermanager

the relationship between the entities Department the relationship between the entities Department and Manager would have the cardinalityand Manager would have the cardinality one-to-one one-to-one. . 学校-校长 学院-院长 等等

Page 70: SSD9-Unit3

The concept of The concept of modalitymodality ( ( 形式形式 ) also extends to ER ) also extends to ER modeling.modeling.

total participationtotal participation in a relationship in a relationship An employee can exist only if he or she works for a

department, making participation in a relationship WORKS_FOR mandatory. ( 必须的 )

partial participation partial participation in a relationshipin a relationship In contrast, the relationship MANAGES, between Employee

and Department is optional, because not every employee must manage a department. ( 可选的 )

Page 71: SSD9-Unit3

the ER diagram might also show attributesthe ER diagram might also show attributes

不只显示关系,也可以显示属性!不只显示关系,也可以显示属性! The choice to modeling …… depends on The choice to modeling …… depends on

an object as an attribute of an entity an object as an entity itself whether you expect such objects to participate in relationships or not. 系统

中有无必要分解到它的属性 E.g.,E.g.,

Departure is modeled as an entity above because, in addition to being linked to Passenger via the Booked_On relationship, Departure also participates in a relationship with Flight.

具体定到那个时间的航班!所以要到作为实体出现在图中! On the other hand, the On the other hand, the Name, Address, and Phone number of Name, Address, and Phone number of

the passengerthe passenger do not participatedo not participate in any other relationship in in any other relationship in this particular problem, so they can be modeled as attributes.this particular problem, so they can be modeled as attributes.

Page 72: SSD9-Unit3

Key Key 键键 A subset of attributes that uniquely identifies an A subset of attributes that uniquely identifies an

entityentity Sometimes a key is a Sometimes a key is a

single attribute, a combination of attributes, often used

E.g.E.g., , cannot use the attribute Name as a key for Passenger because

there are many John Smiths booking flights on airlines. On the other hand, the Name and Phone_Number is probably a

good key. name + address 等也可以 ……

Page 73: SSD9-Unit3

Take Assessment:Take Assessment:

Exercise 2Exercise 2 Multiple-Choice Quiz 3 Multiple-Choice Quiz 3


Recommended