Requirements Analysis

Purpose of Requirements Analysis

Requirements Model (需求模型) serves two key objectives:

  • Confirm what users want a system to do
  • Specify what designers must design

Objectives of Requirements Model

  • Describe what software must do
  • Help analysts understand the system domain
  • Show connections and interactions among people, things, and concepts
  • Show business situations that assist in design evaluation
  • Organize information to be useful for software design

Class Diagram Stereotypes

Analysis class stereotypes (分析类原型) differentiate the roles objects can play:

1. Boundary Objects (边界对象)

  • Model interaction between system and actors (or other systems)
  • Help partition the system during design stage
  • Example: UserInterface::AddAdvertUI

2. Entity Objects (实体对象)

  • Represent information and behavior in the application domain
  • Core business objects that persist
  • Example: Campaign, Client, Advert

3. Control Objects (控制对象)

  • Coordinate and control other objects
  • Manage the flow of a use case
  • Example: Control::AddAdvert

Class Diagram Components

Class Symbol Structure

┌─────────────────────┐
│    Class Name       │  ← Class name compartment
├─────────────────────┤
│    Attributes       │  ← Attributes compartment
├─────────────────────┤
│    Operations       │  ← Operations compartment
└─────────────────────┘

Object Symbol Structure

┌─────────────────────┐
│  ObjectName:Class   │  ← Object name compartment
├─────────────────────┤
│  attribute=value    │  ← Attribute values
└─────────────────────┘

Note: Instances do NOT have operations

Attributes

Attributes (属性) are:

  • Part of the essential description of a class
  • The common structure of what the class can know
  • Each object has its own value for each attribute in its class

Operations

Operations (操作) are:

  • Description of something a class can do
  • The common behavior shared by all objects of the class
  • Services that objects of a class can provide to other objects

What Operations Do

  • Set or reveal attribute values
  • Perform calculations
  • Send messages to other objects
  • Create or destroy links

Associations

Associations (关联) represent:

  • The possibility of a logical relationship or connection between objects
  • If two objects can be linked, their classes have an association

Association Components

  • Association name: Describes the relationship
  • Association role: Labels at each end
  • Direction arrow: Shows reading direction
  • Multiplicity: Number of objects that can participate

Link (链接) is a logical connection between two objects (instances of an association)

Multiplicity

Multiplicity (多重性) is the range of permitted cardinalities of an association

Types of Multiplicity

  • Definite value: 2 (exactly 2)
  • Indefinite value: * (zero or more)
  • Range of value: 5..15 (5 to 15)
  • Set of value: 2, 4, 6 (specific values)

Most Common Multiplicities

  • 0..1 - Zero or one (optional)
  • 0..* - Zero or more
  • 1 - Exactly one (mandatory)
  • 1..* - One or more
  • * - Any number

Multiplicity Rules

Multiplicities represent business rules:

  • Example: “Any bank customer may have one or more accounts”
  • Example: “Every account is for ONE, and ONLY ONE, customer”

Association Degree

Degree (度) denotes the number of classes involved in a connection:

1. Unary (一元)

  • Association from a class to itself
  • Example: Employee manages Employee

2. Binary (二元)

  • Association between two different classes
  • Most common type
  • Example: Teacher teaches CourseOffering

3. Ternary (三元)

  • Association among three classes
  • Example: Part-Vendor-Warehouse relationship

Complex Associations

When associations have many-to-many (..) relationships, they can be resolved using:

1. Association Class (关联类)

  • Used in analysis phase to solve many-to-many relationships
  • Association gets coded as a class
  • Name must be the same as the original association
  • Example: Person-Book “borrow” relationship becomes Borrow class with fromDate, toDate

2. Qualified Association (限定关联)

  • Assigns a unique attribute value/qualifier
  • Reduces many-to-many to one-to-many
  • Example: Bank-Customer relationship qualified by custRef or bankCode

Discovering Entity Classes

Four main approaches to identify classes:

1. Noun Phrase Approach (名词短语方法)

  • Every noun phrase is a candidate class
  • Classify candidates as:
    • Relevant class: Belongs to problem domain
    • Fuzzy class: Not sure (needs analysis)
    • Irrelevant class: Outside problem domain

2. Common Class Pattern (通用类模式)

  • Derives classes from classification theory
  • Common patterns:
    • Concept class: Abstract ideas (e.g., Reservation)
    • Events class: Things that happen (e.g., Arrival)
    • Organization class: Groups (e.g., Department)
    • People class: Actors (e.g., Passenger)
    • Places class: Locations (e.g., TravelOffice)

3. Use Case Realization (用例实现)

  • From use case to collaboration and class diagrams
  • Process:
    1. Create use case diagram
    2. Identify participating classes (collaboration)
    3. Create collaboration diagram showing interactions
    4. Derive class diagram with attributes and operations

4. CRC Technique

CRC (Class-Responsibility-Collaboration) cards help model object interactions

CRC Card Format

┌─────────────────────────────────────┐
│ Class Name: [noun]                  │
├──────────────────┬──────────────────┤
│ Responsibilities │ Collaborations   │
│                  │                  │
│ Operations of    │ Classes that     │
│ the class        │ help fulfill     │
│                  │ responsibilities │
└──────────────────┴──────────────────┘

CRC Process

  1. Brainstorm the objects
  2. Allocate to team members
  3. Role play the interaction
  4. Act out the use case
  5. Identify missing/redundant objects

CRC Benefits

  • Verification of classes discovered with other methods
  • Determination of class properties
  • Interactive team approach to class discovery

Key Exam Points

True/False Concepts

  • Boundary objects model interaction between system and actors ✓
  • Entity objects represent information and behavior in the application domain ✓
  • Control objects coordinate other objects ✓
  • Each object has its own value for each attribute ✓
  • Operations describe what instances can do ✓
  • Associations have multiplicity ✓

Remember

  • Attributes = What a class knows
  • Operations = What a class can do
  • Associations = How classes relate
  • Multiplicity = Business rules about relationships
  • Stereotypes = Roles objects play (Boundary, Entity, Control)