1、Object-Oriented and Classical Software Engineering Seventh Edition, WCB/McGraw-Hill, 2007,CHAPTER 10,REQUIREMENTS,第二部分 软件生命周期的各个工作流,将给出适合每个工作流的活动、CASE工具、度量和测试技术 第十章 研究需求流。这一工作流的目标是确定客户的真正需求及研究各种需求分析技术 “传统的分析”描述传统的方法,给出规格说明的三种基本方法(非形式化的、半形式化的和形式化的) “面向对象分析”描述面向对象的方法 “设计”中,对何种设计技术进行比较,包括数据流分析和事务分析这样传统
2、技术及面向对象设计。 “实现”讨论实现问题,涉及的领域包括实现、集成、好的编程实践和标准 “交付后维护”讨论的主题包括交付后维护的重要性和面临的挑战,Overview,Determining what the client needs Overview of the requirements workflow Understanding the domain The business model Initial requirements Initial understanding of the domain: The MSG Foundation case study Initial busi
3、ness model: The MSG Foundation case study,学习目标: 完成需求流的任务; 提出初始业务的模型; 提出需求; 构造快速原型;,Overview (contd),Initial requirements: The MSG Foundation case study Continuing the requirements workflow: The MSG Foundation case study Revising the requirements: The MSG Foundation case study The test workflow: The
4、MSG Foundation case study The classical requirements phase Rapid prototyping,Overview (contd),Human factors Reusing the rapid prototype CASE tools for the requirements workflow Metrics for the requirements workflow Challenges of the requirements workflow,The Aim of the Requirements Workflow,To answe
5、r the question:What must the product be able to do? 将一个产品按时而又不超出预算地开发出来的机会是很小的,除非软件开发小组成员对软件产品将做什么意见一致 回答这个问题的过程就是需求流的基本目标,10.1 Determining What the Client Needs,误解之一:开发者想确定客户想要什么软件Misconception We must determine what the client wants美国议员著名的托辞:“I know you believe you understood what you think I said
6、, but I am not sure you realize that what you heard is not what I meant!”-我知道你自以为理解了我所说的,但是我不确定你能认识到你听到的并不是我所意指的We must determine what the client needs,Determining What the Client Needs (contd),要确定客户需要什么看起来简单-好像只要询问就可以了.但有两个原因说明它是很难的 客户可能没有意识到自己的公司正在做什么。客户经常要求一个错误的软件产品是因为软件很复杂。It is hard for a syste
7、ms analyst to visualize a software product and its functionality The problem is far worse for the client 没有专业小组的协助,客户很难了解到需要开发什么的相关信息。A skilled systems analyst is needed to elicit the appropriate information from the client The client is the only source of this information,Determining What the Clien
8、t Needs (contd),The solution: Obtain initial information from the client Use this initial information as input to the Unified Process Follow the steps of the Unified Process to determine the clients real needs,10.2 Overview of the Requirements Workflow,First, gain an understanding of the application
9、 domain (or domain, for short)理解应用域 The specific environment in which the target product is to operateSecond, build a business model Model the clients business processes通常用UML图来描述客户的商业过程Third, use the business model to determine the clients requirementsIterate the above steps,Definitions,Discovering
10、 the clients requirements Requirements elicitation (or requirements capture)需求启发 Methods include interviews and surveysRefining and extending the initial requirements 推敲和扩充的过程称为需求分析 Requirements analysis具体讨论这些步骤,10.3 Understanding the Domain,Every member of the development team must become fully fam
11、iliar with the application domain Correct terminology is essential 举例:brace(支柱)、Beam(横梁)girder(大梁)、strut(撑杆)-这些看来近似的词对一个土木工程师来说是截然不同的四个词。如果理解不好可能会对生产的计算机辅助桥梁设计软件包含错误,造成桥梁倒塌等严重事件 为避免对术语的理解错误需要建立术语表 Construct a glossary A list of technical words used in the domain, and their meanings-在该领域应用的技术词汇列表和对应的
12、解释。,10.4 Business Model,A business model is a description of the business processes of an organization 举例:银行的一些商业过程包括从客户接受存款、贷款给客户和进行投资。 建立商业模型的原因:The business model gives an understanding of the clients business as a whole This knowledge is essential for advising the client regarding computerizatio
13、n-需要对客户生意的那些部分进行计算机化 The systems analyst needs to obtain a detailed understanding of the various business processesDifferent techniques are used, primarily interviewing访谈,10.4.1 Interviewing,需求小组的成员会见客户公司的成员,直到他们确信已经从客户和目标软件产品未来的用户处得到启发并获得了所有的相关信息 The requirements team meet with the client and users
14、 to extract all relevant information,Interviewing (contd),There are two types of questions 受限回答的问题-Close-ended questions require a specific answer,举例“公司雇佣了多少销售员?或要求的响应时间是多快? 自由回答的问题-Open-ended questions are posed to encourage the person being interviewed to speak out举例”为什么当前的产品不令人满意呢? 采取的措施:There ar
15、e two types of interviews访谈 程式化的-In a structured interview, specific preplanned questions are asked, frequently close-ended 通常是受限回答的问题 非程式化的-In an unstructured interview, questions are posed in response to the answers received, frequently open-ended先提出一两个事先准备好的问题,接下来则是根据受访者的回答提出,大多数这些问题是自由回答,能够给访问者提
16、供很宽范围的信息,Interviewing (contd),Interviewing is not easy An interview that is too unstructured will not yield much relevant information,比如说问“请谈谈你的生意?” The interviewer must be fully familiar with the application domain The interviewer must remain open-minded at all times After the interview, the interv
17、iewer must prepare a written report It is strongly advisable to give a copy of the report to the person who was interviewed-因为他或她可能会想澄清某些陈述或增加一些被忽略的项目,10.4.2 Other Techniques,Interviewing is the primary technique 当然还有其它可以结合使用的技术 调查问卷-A questionnaire is useful when the opinions of hundreds of individ
18、uals need to be determined客户在业务上使用的各种表格-Examination of business forms shows how the client currently does business,Other Techniques (contd),直接观察-Direct observation of the employees while they perform their duties can be useful Videotape cameras are a modern version of this technique But, it can take
19、 a long time to analyze the tapes Employees may view the cameras as an unwarranted invasion of privacy,10.4.3 Use Cases,关于用例 A use case models an interaction between the software product itself and the users of that software product (actors)-用例为软件产品本身和软件产品的使用者之间的交互建立模型. Example:,Figure 10.1,Use Case
20、s (contd),参与者-An actor is a member of the world outside the software productIt is usually easy to identify an actor An actor is frequently a user of the software productIn general, an actor plays a role with regard to the software product. This role is As a user; or As an initiator; or As someone wh
21、o plays a critical part in the use case,Use Cases (contd),A user of the system can play more than one roleExample: A customer of the bank can be A Borrower or -借钱人(贷款) A Lender -借出者(存款),Use Cases (contd),Conversely, one actor can be a participant in multiple use cases一个参与者可以参加多个用例Example: A Borrower
22、 may be an actor in The Borrow Money use case; The Pay Interest on Loan use case; and The Repay Loan Principal use case Also, the actor Borrower may stand for many thousands of bank customers,Use Cases (contd),An actor need not be a human beingExample: An e-commerce information system has to interac
23、t with the credit card company information system The credit card company information system is an actor from the viewpoint of the e-commerce information system The e-commerce information system is an actor from the viewpoint of the credit card company information system,Use Cases (contd),A potentia
24、l problem when identifying actors Overlapping actors-重叠参与者Example: Hospital software product One use case has actor Nurse A different use case has actor Medical Staff Better: Actors: Physician and Nurse,Use Cases (contd),Alternatively: Actor Medical Staff with two specializations: Physician and Nurs
25、e,Figure 10.2,10.5 Initial Requirements初始需求,The initial requirements are based on the initial business modelThen they are refinedThe requirements are dynamic there are frequent changes Maintain a list of likely requirements, together with use cases of requirements approved by the client 处理这些频繁变化的好方法
26、是维护一个可能的需求表,带有需求的用例,这些用例得到了开发小组个成员和客户的认可,Initial Requirements (contd),There are two categories of requirements 两种类型的需求: A functional requirement specifies an action that the software product must be able to perform Often expressed in terms of inputs and outputs 亦即有一个什么输入就会有一个什么输出 A nonfunctional req
27、uirement specifies properties of the software product itself, such as Platform constraints Response times Reliability,Initial Requirements (contd),在需求和分析流进行功能需求的处理-Functional requirements are handled as part of the requirements and analysis workflowsSome nonfunctional requirements have to wait until
28、 the design workflow The detailed information for some nonfunctional requirements is not available until the requirements and analysis workflows have been completed,10.6 Initial Understanding of the Domain: MSG Case Study,通过一个运行实例研究阐述需求流 The Martha Stockton Greengage Foundation (“MSG”) provides low
29、cost mortgage loans to young couples 为了降低运行费用,MSG基金会的理事正向计算机行业投资.因为没有哪个理事有计算机方面的经验,他们决定委托一个小的软件开发小组来实现一个向导项目,即一个软件产品,用来计算为购买房屋每周需要多少钱. The trustees commission a pilot project A software product to determine how much money is available each week to purchase homes,Initial Understanding of the Domain:
30、MSG Case Study (contd),A mortgage is a loan in which real estate is used as securityExample: House costs $100,000Buyer pays a 10% deposit and borrows the balance The principal (or capital) borrowed is $90,000Loan is to be repaid monthly over 30 years Interest rate of 7.5% per annum (or 0.625% per mo
31、nth),Initial Understanding of the Domain: MSG Case Study (contd),Each month, the borrower pays $629.30 Part of this is the interest on the outstanding balance The rest is used to reduce the principalThe monthly payment is therefore often referred to as P & I (principal and interest),Mortgage Payment
32、s: First Month,In the first month the outstanding balance is $90,000 Monthly interest at 0.625% on $90,000 is $562.50 The remainder of the P & I payment of $629.30, namely $66.80, is used to reduce the principal At the end of the first month, after the first payment has been made, only $89,933.20 is
33、 owed to the finance company,Mortgage Payments: Second Month,In the second month the outstanding balance is $89,933.20 Monthly interest at 0.625% on $89,933.20 is $562.08 The remainder of the P & I payment of $629.30, namely $67.22, is used to reduce the principal At the end of the second month, aft
34、er the second payment has been made, only $89,865.98 is owed to the finance company,Mortgage Payments: After 15 and 30 Years,After 15 years (180 months) the outstanding balance is $67,881.61 Monthly interest at 0.625% on $67,881.61 is $424.26 The remainder of the P & I payment of $629.30, namely $20
35、5.04, is used to reduce the principal After 30 years (360 months), the entire loan will have been repaid 金融公司想要确保它借出的9万美元能够还清,并包括利息,可以有几种方式,Insurance Premiums,保险税的处理 The finance company requires the borrower to insure the house If the house burns down, the check from the insurance company will then
36、be used to repay the loan,Insurance Premiums (contd),The insurance premium is paid once a year by the finance company The finance company requires the borrower to pay monthly insurance installments These are deposited in an escrow account (a savings account)-金融公司要求借钱者支付每月的保险部分,将它存入一个第三方帐户(由第三方保存帐户契约
37、)The annual premium is then paid from the escrow account,Real Estate Taxes,不动产税的处理:Real-estate taxes paid on a home are treated the same way as insurance premiums Monthly installments are deposited in the escrow account The annual real-estate tax payment is made from that account,Borrowing Limits,抵押
38、方式的考虑:A mortgage will not be granted unless the total monthly payment (P & I plus insurance plus real-estate taxes) is less than 28% of the borrowers total income,Other Costs,借钱的一点提前回报:The finance company requires a lump sum up front in return for lending the money to the borrower Typically, the fin
39、ance company will want 2% of the principal (“2 points”) For the $90,000 loan, this amounts to $1,800,Other Costs (contd),There are other costs involved in buying a house Legal costs诉讼费 Various taxes-税When the deal is “closed,” the closing costs (legal costs, taxes, and so on) plus the points can eas
40、ily amount to $7,000 国内的贷款相关费用: A、服务费:贷款额2%(最低1000元); B、评估费:评估价5(最低收费400元); C、公证费:贷款额1; D、抵押登记费:80元; E、保险费:(贷款本息和与房价之比)的最低值0.5系数(贷款年限+1)。 (二)交易费用: A、契税:成交价格(市场价格)1%(房屋单价3000元/平方米的为1.5%); B、住房所有权登记费:80元; C、印花税:按合同记载金额的0.5计税;房屋权属证书每本5元; D、住房转让手续费:建筑面积6元/平方米; E、土地出让金:成交价格(市场价格)1%;土地权属证书每本5元。,Initial Gl
41、ossary,Figure 10.3,初始的术语表如下:,余额:仍欠的借款数额 资金:本金的意思 手续费:诉讼费及税等 保证金:房子总费用中初始支出 第三方账户:由金融公司管理的 一个账户,按周存入年保险费和 年不动产税,再从中支付年保险 费和年不动产税 利息:借钱的费用 抵押:在借款中以不动产作为保证 P&I:”本金和利息“ 点:借钱的费用 本金:借款的总数 本金和利息:由利息和一部分本金组 成的支付的部分,10.7 Initial Business Model: MSG Case Study,现在可以开始构建MSG基金实例研究的初始业务模型了 开发组成员经过访问了解了基金会运作的方式: 在
42、每周的开始,MSG基金会估算这周将有多少钱可以用来自助受押人。收入太低无法负担标准抵押的夫妇可以在任何时候向MSG申请抵押。MSG人员首先确定该夫妇是否具有资格申请,然后确定MSG基金会那一周手头是否有足够的资金来购买房子。如果是,就可以确认这项抵押。同时根据夫妇目前收入的情况,这个偿还额每周会变化。 由此构建初始业务模型的关键文字描述按以下步骤: At the start of each week, MSG estimates how much money will be available that week to fund mortgages-每周有多少钱可以用来抵押。 Low-inco
43、me couples can apply at any time-收入太低无法负担标准抵押的夫妇随时可以申请,Initial Business Model: MSG Case Study (contd),An MSG Foundation staff member determines两件事情要决定 Whether the couple qualifies for an MSG mortgage, and Whether MSG has sufficient funds on hand to purchase the homeIf so, the mortgage is granted The
44、 weekly mortgage repayment is computed according to MSG rules-根据MSG规则计算每周抵押偿还额.This repayment amount may vary from week to week, depending on the couples current income-偿还额度会依据收入而变化,Initial Business Model: MSG Case Study (contd),因此对应的业务模型应该包含三个用例: 关于用例 There are three use cases(或称为三个基本的功能) Estimate
45、Funds Available for Week-估算本周可用的资金 Apply for an MSG Mortgage-申请抵押 Compute Weekly Repayment Amount-计算每周偿还额度 下面分别对这三个用例进行分析,关于用例,Use Case的定义是:在不展现一个系统或子系统内部结构的情况下,对系统或子系统的某个连贯的功能单元的定义和描述。有点拗口,对吧?其实Use Case就是对系统功能的描述而已,不过一个Use Case描述的是整个系统功能的一部分,这一部分一定要是在逻辑上相对完整的功能流程。,Estimate Funds Available for Week
46、Use Case,Figure 10.4,Figure 10.7,第一个用例: 估计本周可用的资金,Apply for an MSG MortgageUse Case,Figure 10.5,Figure 10.8,第二个可能的用例: 处理申请抵押,Compute Weekly Repayment Amount Use Case,Figure 10.6,Figure 10.9,第三个可能的用例:计算每周的偿还额,Who Is an Actor?,关于参与者 从用例图来看看: 谁真正的参与者? Why is Applicants an actor in use case Apply for an
47、 MSG Mortgage? 表面看: Applicants do not interact with the software product Their answers are entered into the software product by an MSG staff member,Who Is an Actor? (contd),However, 但申请者发起了用例 The applicants initiate the use case The applicants provide the data entered by MSG staff The real actor is
48、therefore Applicants the MSG Staff Member is merely an agent of the applicants结论:Applicants is therefore indeed an actor-申请者就是参与者,Who Is an Actor? (contd),再看另外一个用例图10.6 Similarly, Borrowers is an actor in use case Compute Weekly Repayment Amount Again the use case is initiated by actor Borrowers Aga
49、in the information entered by MSG staff is supplied by the borrowersThus, Borrowers is indeed an actor in the use case 结论:借钱者是真正的参与者,Manage an InvestmentUse Case,还有一个模型是涉及到MSG的投资的,该阶段有些细节尚不清楚,比如 At this stage, no details are known regarding The buying and selling of investments, or How investment income becomes available for mortgages但可以确认是有第四个用例是初始商业模型的一部分However, use case Manage an Investment is an essential part of the initial business model,Manage an InvestmentUse Case (contd),Figure 10.10,Figure 10.11,