代码改变世界

Head First Object-Oriented Design and Analysis学习笔记(二)

2010-07-23 20:25  Aga.J  阅读(311)  评论(0编辑  收藏  举报

第二章

Gather requirements

Give Them What They Want

前言:

  本章仍然使用一个例子来说明本章主题—挖掘用户需求,介绍了如何一步一步挖掘用户需求和需求的文档化。

案例分析:

案例描述:

       Doug’s dog door,一个可以让用户开启狗门的系统,用户给出的功能性需求很少,只是说到晚上狗在叫时要开门让狗出去。

初步设计为

Public class DogDoor

{

       Private Boolean open;

       Public DogDoor()

{

       This.open=false;

}

Public void open()

{

       System.out.println(“The dog door opens”);

       This.open=true;

}

Public void close()

{

       System.out.println(“The dog door closes”);

       This.open=false;

}

Public Boolean isOpen()

{

       Return open;

}

}

Public class Remote

{

       Private DogDoor door;

       Public Remote(DogDoor door)

{

       This.door=door;

}

Public void pressButton()

{

       System.out.println(“Pressing the remote control button..”);

       If(door.isOpen())

{

door.close();

}

Else

{

Door.open();

}

}

}

问题提出:

1 每次狗要出去时才叫,然后用户按下按钮,门就开,然后狗进来时并不叫,用户并不知道什么时候关门好。(这就是用户的潜在需求)

问题解决:

1(1)listen to the customer (2)Creating a requirement list{把用户的需求写进list里面记录下来}

(3)写出整个关键点流程或者是一个完整的过程流程。{比如这个例子里的门的使用流程}(4)plan for things going wrong充分考虑到不同环境或者不同情况下的系统使用情况,从而挖掘出更多需求{然后把这些做为可选流来update到前面写的list中},最后修改list满足客户要求。最后通过设置一个计时器来完成门的自动关闭。

Important Point:

1 you have to ask the customer questions to figure out what they want before you can determine exactly what the system should do. Then you can begin to think beyond what your customers asked for and anticipate their needs, even before they realize they have a problem.

2 The best way to get good requirements is to understand what a system is supposed to do

3 a single user case focuses on a single goal

4 each use case provides one or more scenarios that convey how the system should interact with the end user or another system to achieve a specific goal

5 每个用例都需要有一个clear value(achieve one goal),还有一个起始点和终点,最后还需要一个外部的启动者来启动用例。

6 plan and test for when things go wrong

7 external initiator: kicks off the list of steps described in a use case

  Use case: help you gather good requirements. Tell a story about how the system works

  Start Condition: first step in the use case

  Requirement: something a system has to do to be a success

  Clear value: use case without this always fail

  Stop Condition: finish step

  Main Path: how a system works when everything goes right

8 Good requirements ensure your system works like your customers expect

9 make sure your requirements cover all the steps in the use case for your system

10 Use your use cases to find out things your customers forgot to tell

11 Your use case will reveal any incomplete or missing requirements that you might have to add to your system.

12 to make sure you have a good set of requirements, you should develop use case for your system

13 use case detail exactly what your system should do. A use case has a single goal, but can have multiple paths to reach the goal

14 After your use cases are complete, you can refine and add to your requirements

小结:开发系统,对用户的需求分析是引领这个系统走向正确(即很好的满足客户要求,包括潜在的需求和意外环境下的运行)的重要步骤,只有通过和客户沟通,勾勒出客户基本需求,然后建立use case来描述相关信息(Primary Actor, Secondary Actor, Preconditions, goal, main path, extensions=optional path),然后从这些use case中找到真正的requirements,并且发现潜在的功能性requirements或者完善不完全或忽略了的需求。本章关于用户需求的挖掘还是简单了点,但是可以通过这个例子看到,就算是一个这么简单的系统,关于用户的需求还是很难满足的,所以对于用户需求要很重视,做好use case,很好的考虑各种情况,从而得到一份比较好的requirements。