During the Analysis Phase the developer, client, users, and other stakeholders work together to produce a specification document, which will be the input to the design phase. A typical specification document includes the following sections:
The requirements model describes the functional and non-functional requirements of the system. More on this below.
The domain model describes the application domain-- the real world context of the system under development. The domain model captures the important concepts and relationships that impact the system. Class and object diagrams are used as domain models.
The deployment model describes the assignment of system components to computers and other devices on a network. More on this later.
The schedule lists the project milestones in the order they will be attacked along with an estimate of the number of man-hours, days, or weeks needed to complete the milestone.
The glossary defines application domain terms. Sometimes a misunderstanding over terminology can be the source of a bug. For example, a matriculation system keeps track of the progress students at a university make toward their degree objectives. But what is the definition of a student? Does the system track extension students? Students who stop out for several semesters? Part-time students? Probationary students?
The requirements model is the result of a sub-phase of analysis called Requirements Capture. During this phase the developer interviews clients, users, and other stakeholders. Similar systems are researched, and literature surveys are conducted.
During this phase two types of requirements are captured:
The system must allow customers to place and track orders. Customers who don't know exactly what they want should be able to browse the online product catalog. Customers should be able to pay for their orderds online using any major credit card.
It's important for the developer to keep the distinction between functional and non-functional requirements clear. The distinction often isn't appreciated by clients and users. The requirements model section of our specification document is divided into two subsections-- one for functional requirements, the other for non-functional requirements.
Functional Requirements
Technically, a functional requirement describes some function that the system computes. We can understand this as a mathematical function of the form:
Action* = the set of all sequences of system actions, such as computing a result, displaying an error message, prompting the user for more input, disabling a menu item, etc.
Sometimes we can do better than stimulus-response chains. For example, a typical trigonometry book describes the sine function mathematically, in terms of circles and right triangles, without ever describing an algorithm for computing the sine of a number.
In practice, the functions computed by a commercial software system are often too complex or too ambiguous to be completely specified by mathematical definitions. Also, Mathematical definitions might be too technical for a specification document, which needs to be understood by clients as well as developers. Nevertheless, developers should keep the mathematical definition of a function in mind as an idealized goal of the specification process.
Use Cases
In UML functional requirements are called use cases. A use case diagram shows the system use cases, their relationships to each other, and to the actors (users) who invoke them.
Here is a partial use case diagram for a calculator:
The elliptical icons are the use cases. The stick figures are the actors who interact with the calculator.
Actors
An actor can be a human (User, Engineer, Accountant) or a remote system (Printer). Actors are classes. For example, a particular user, Dilbert, can be regarded as an instance of the Engineer class. As such actors can have the same relationships between them as the classes in a class diagram. Note, for example, the specialization relationship between Accountant and User.
The arrow connecting an actor to a use case is called an actor association. For example, the arrow connecting User to the Enter Number use case says that Users and Enter Number will interact (stimulus-response, press keys-display digits) to accomplish the task of entering a number. The direction of the arrow indicates who begins the interaction. For example, if the calculator is connected to a printer, then the Display Number use case initiates the interaction with the printer.
Generalization
Although a use case describes a function, use cases bare some resemblance to classes. For example, if we identify a use case with a function declaration:
Of course a user can create and send a new email message, but forwarding or replying to an email message are special cases of sending an email message. Although the user command for reply and forward are different from send, we don't need to show actor associations to these use cases, because here, as in a class diagram, the generalization arrow implies inheritance. In particular, the Forward, Reply, and Reply All inherit the user association from the Send use case, as well as the "includes" relationship to the Edit use case.
As with classes, we can also define abstract use cases. In our calculator example Apply Function, Trig, Finance, and Arithmetic are abstract use cases. It doesn't make sense for the user to instantiate (i.e., invoke or call) the Trig use case. Rather the user instantiates the Sine, Cosine, and Tangent use cases that specialize the Trig use case. (These use cases are not shown in our diagram.) Some CASE tools allow developers to stereotype abstract use cases. Abstract use cases are handy when they describe a cohesive family of use cases to which they can bequeath relationships to other use cases and actors.
Includes and Extends
If we push the analogy between use cases and functions, then we can think of the includes relationship between use case A and use case B as the relationship "function A calls supporting function B."
The arrow points from the caller, A, to the supporting function, B. As a supporting function, B normally wouldn't have actor associations, and would normally be included by two or more use cases.
The extends relationship is hard to define. If use case C extends use case A, then at some point during the execution of A, control may be transferred to B. This transfer may be implicit. It may be caused by some exceptional condition that arises, while the transfer of control from A to B is explicit. We will use the extends relationship for exception and interrupt handling.
For example, when a user saves a word processor document, this may throw an exception if the document hasn't been saved before. This invokes the First Save exception handler, which, like the Open Document use case, calls the Get Document use case:
Use Case Elaborations
By itself, a use case diagram isn't very useful. Each use case must be elaborated. A use case elaboration usually has the form: