SEN2022 · Week 11 · Validating and Evolving Analysis Models

Verifying and evolving the analysis models: walkthrough, balancing, layers

Checking whether the functional, structural and behavioral models are consistent within themselves and with each other (walkthrough, balancing), then factoring, packages and layers to move to design. The exam asks 'what is inconsistent in these models?'.

verificationvalidationwalkthroughpresenterrecorder (scribe)maintenance oraclebalancing the modelsconsistencyfactoringabstractionrefinementpartitioncollaborationpackagepackage diagramdependencylayerproblem domain layerdata management layerhuman-computer interaction layerphysical architecture layerfoundation layer

At the end of the analysis phase you have three models: functional (use case diagram, descriptions, activity diagrams), structural (CRC, class, object diagram) and behavioral (sequence, communication, state machine). These models were drawn by different people at different times. Before moving to design, two questions are asked: Is each model correct within itself? Are the models consistent with each other? Moving to design with inconsistent models is like building a building from a wrong plan. On the exam, two or three model fragments are given and you are told “find the inconsistencies”.

Golden rules:

  1. Verification: are we building the models right? Validation: are we modeling the right system?
  2. A walkthrough finds the error, it does not fix it.
  3. Everything comes from somewhere and goes somewhere: every class appears in a use case, every message is an operation, every event is a message.
  4. If you change one model, update the others too.

Walkthrough

A walkthrough is a step-by-step review of a model by the team. The model is tested by eyes other than those of the person who made it.

RoleTask
PresenterExplains the model, usually the analyst who made it
Recorder (scribe)Writes down the errors, questions and suggestions found
Maintenance oracleQuestions it from the point of view of maintenance, standards and compatibility with existing systems
Other participantsUsers and analysts; they ask questions and catch errors

Rules:

  • The goal is to find errors, not to fix them. Fixing is done after the session.
  • The model is evaluated, not the person. That is why the presenter’s manager usually does not attend.
  • If users take part, the walkthrough is also validation: “Does this describe your work correctly?”
  • It is done early and often; the later an error is found, the more expensive it is.

Verifying each model within itself

Functional model:

  • Does every use case in the use case diagram have a description? Does every description correspond to an oval in the diagram?
  • Is the “relationships” field in the description the same as the include/extend/generalization in the diagram?
  • Does every action in the activity diagram correspond to a description step (and vice versa)?
  • Does every object node in the activity diagram correspond to a noun that appears in the descriptions?

Structural model:

  • Does every CRC card correspond to a class? Do the “collaborators” on the cards exist as relationships in the class diagram?
  • Are the “knowing” responsibilities on the cards the attributes of the class, and the “doing” responsibilities its operations?
  • Does the object diagram violate the multiplicities in the class diagram?

Behavioral model:

  • Are the messages in each sequence diagram the same as in the communication diagram?
  • Does every state and transition in the state machine reflect the real life cycle of the object (as described in the descriptions)?

Balancing the models

The three models are compared in pairs.

           Functional
          (use case,
           activity)
           /       \
          /         \
 Structural ------- Behavioral
 (CRC, class,       (sequence,
  object)            comm., state)

Functional ↔ structural

CheckExample
Every important noun in the descriptions should be a class or attribute“reservation code” → Reservation.code
Every class should appear in at least one descriptionThe never-used “Coupon” class → a missing requirement or an unnecessary class
Object nodes in the activity diagram should be classesOrder [paid] → the Order class, a status attribute
Relationships in the description (a student reserves a copy) should be relationships in the class diagramStudent - Reservation - Copy

Functional ↔ behavioral

CheckExample
There should be a sequence diagram for every use case (at least the normal flow)Reserve Book → Reserve Book sequence
The actors in the sequence should be the same as the actors in the use case diagramIt must not say “Student” in the diagram and “Member” in the sequence
Sequence messages should correspond to the description steps8 steps ↔ messages

Structural ↔ behavioral

CheckExample
Every lifeline in the sequence should be an object of a class:Copy → the Copy class
Every message should be an operation of the receiving classsetStatus() → Copy.setStatus()
If two objects exchange messages, there should be a relationship between their classesController-Copy exchange messages → a relationship or a temporary link
The class of the state machine should be in the class diagram; states should correspond to attribute valuesCopy.status ∈ {Available, On Hold, …}
State machine events should be operations of the class or incoming messagespickUp → Copy.pickUp()

Worked example: find the inconsistency

Three fragments from the gym system:

Use case description (Book Class), normal flow:

1. The member views the class list.
2. The member selects a class.
3. The system verifies the membership.
4. The system checks that the class has a free place.
5. The system creates a reservation.
6. The system shows a confirmation.

Class diagram (relevant part):

ClassOperations
MembergetStatus()
ClassSessiongetCapacity(), listSessions()
Bookingcreate()

Sequence diagram messages:

1 aMember -> :BookingCtrl : selectSession()
2 :BookingCtrl -> :ClassSession : listSessions()
3 :BookingCtrl -> :Member : verifyMembership()
4 :BookingCtrl -> :ClassSession : hasFreeSeat()
5 :BookingCtrl -> :Booking : create()
6 :BookingCtrl -> :Trainer : notifyTrainer()

Inconsistencies found:

#ProblemTypeFix
1In the sequence, listSessions (step 1) comes after selectSession (step 2)Functional ↔ behavioral (order)First listSessions, then selectSession
2verifyMembership() is not in Member; Member has getStatus()Structural ↔ behavioralAdd the operation or change the message to getStatus()
3hasFreeSeat() is not in ClassSessionStructural ↔ behavioralAdd the operation (or check with getCapacity)
4There is a :Trainer lifeline but no Trainer class in the class diagram and no trainer notification in the descriptionAll three modelsIs it a requirement? Ask the user; if so, add a step to the description and a class to the class diagram; if not, delete the message
5:BookingCtrl is not in the class diagramStructural ↔ behavioralAdd the controller class to the class diagram (or in analysis let the actor talk directly to the objects)

Evolving the models: the bridge to design

The verified models are prepared for design.

Factoring

Extracting common behavior into a separate class or module.

  • Abstraction: gather common properties into a superclass. The name, phone and e-mail attributes of Member and Trainer → Person.
  • Refinement: split a class into specific subclasses. Membership → MonthlyMembership, AnnualMembership.

Partitions and collaborations

Classes that exchange many messages with each other form a collaboration and can be grouped as a partition (subsystem). The criterion: the number of messages between them (the CRUDE matrix shows this). If the reservation, class and membership classes work together, they become a “Booking” subsystem.

Packages and the package diagram

A package is a container that groups related elements (classes, use cases). A package diagram shows the packages and the dependency relationship (dashed arrow) between them.

+----------+     +-----------+     +----------+
|    UI    |- - >|  Domain   |- - >|   Data   |
+----------+     +-----------+     +----------+

Dependency: if Domain changes, UI may be affected. In a good design, dependencies are one-directional and acyclic.

Layers

LayerContentExample
FoundationBasic classes, data structuresDate, String, List
Problem domainBusiness classes from analysisMember, ClassSession, Booking
Data managementPersistence, database accessBookingDAO, database connection
Human-computer interactionInterfaceScreens, forms, buttons
Physical architectureRelated to hardware, network, operating systemServer communication, deployment

In analysis only the problem domain layer is modeled. In design the other layers are added; week 12 covers the physical architecture layer.

Common mistakes

Wrong ideaThe truth
Verification = validationVerification is building the model right, validation is building the right system
Fix the error immediately in a walkthroughRecord it, fix it later
A manager attending would be goodIt creates a defensive reflex; usually they do not attend
If each model is correct separately, we are doneThe models must also be balanced with each other
An unused class is harmlessA sign of a missing requirement or unnecessary complexity
A message name can differ from the operationA message is an operation of the receiver; the names must be the same
UI and database classes are drawn in analysisIn analysis the problem domain; the other layers in design
Package dependencies can be bidirectionalAvoid cyclic dependencies

Test yourself

Exam-style questions. Solve them on paper first, then reveal the answer.

Question 1easy

What is the difference between verification and validation?

Show answer
Verification: are we building the models right (correct, consistent)? Validation: are we building the right system (does it meet user needs)?

Verification checks the internal correctness and consistency of the model: does it follow the rules, are the models compatible with each other. Validation checks whether the model meets the real need: it is reviewed together with the users.

Question 2medium

In a walkthrough, who answers questions about how the model would affect future maintenance and checks it against existing systems and standards?

  1. Presenter
  2. Recorder
  3. Maintenance oracle
  4. Project sponsor
Show answer
C) Maintenance oracle

The presenter explains the model (usually the analyst who made it). The recorder (scribe) notes the errors and suggestions found. The maintenance oracle looks at whether the model will cause problems with regard to maintenance, standards and compatibility with existing systems.

Question 3medium

Why should the person who built the model NOT be the one who fixes problems during the walkthrough?

Show answer
The walkthrough's goal is to find problems, not to fix them; fixing during the session wastes time and makes it defensive.

In a walkthrough, errors are identified and recorded, and the fixing is done afterwards. Fixing by discussion in the session wastes time. Also, a walkthrough evaluates the model, not the person; managers usually do not attend, so that people do not become defensive.

Question 4medium

An activity diagram contains the action 'Apply Discount', but no use case and no use case description mention discounts. What kind of problem is this?

  1. A structural-behavioral imbalance
  2. A functional model inconsistency (activity diagram vs use cases)
  3. A physical architecture problem
  4. Not a problem
Show answer
B) A functional model inconsistency (activity diagram vs use cases)

Within the functional model, the activity diagram and the use case descriptions must be balanced: every action must correspond to a use case step, and every use case step to an action. Either the description is missing something or the diagram has an extra action.

Question 5easy

A sequence diagram sends calculateFine() to :Loan, but the Loan class in the class diagram has no such operation. Which models are out of balance?

Show answer
Structural and behavioral models (class diagram vs sequence diagram)

Rule: every message in the sequence diagram must be an operation of the receiving class. Either calculateFine() is added to the class diagram, or the message is directed to the right class.

Question 6medium

The class diagram has a class 'Coupon', but no use case description, CRC card or interaction diagram ever uses it. What should the analyst do?

Show answer
Either find the missing requirement/use case that uses Coupon and add it, or remove Coupon from the class diagram.

The structural model and the functional model must be balanced: every class should come from a noun that appears in at least one use case description. An unused class is either a sign of a missing requirement (ask the user) or unnecessary (delete it).

Question 7hard

A state machine for Order has a transition triggered by refund(), but no sequence diagram ever sends refund() and Order has no refund operation. List the two fixes needed for balance.

Show answer
Add refund() as an operation of Order (class diagram) and show it in an interaction diagram (and use case) that triggers it.

Every event in a state machine must correspond to an operation (or an incoming message). The interaction that triggers the event must also be based on a use case. Otherwise the state transition never happens.

Question 8medium

What is factoring?

Show answer
Separating out a module or class that has common behavior (e.g., creating a superclass or a shared class) from existing classes.

Factoring is extracting common behavior into a separate module. Two ways: abstraction (gathering common properties in a superclass: Student and Librarian → Person) and refinement (splitting a class into more specific subclasses).

Question 9easy

Which layer contains the classes identified during analysis, like Book, Copy and Reservation?

  1. Foundation
  2. Problem domain
  3. Data management
  4. Human-computer interaction
Show answer
B) Problem domain

The business classes from analysis are the problem domain layer. Foundation is basic data structures (Date, String, collections), data management is persistence (database access), human-computer interaction is the interface (screens, forms), and physical architecture is classes related to hardware/network.

Question 10medium

In a package diagram, what does a dashed arrow from package UI to package Domain mean?

Show answer
A dependency: UI depends on Domain, so a change in Domain may require a change in UI.

A package diagram shows packages and the dependencies between them. The dashed arrow is a dependency; the arrow goes from the dependent to the one depended upon. In a good design the dependency is one-directional: UI → Domain → Data, not the reverse.

Question 11easy

Name the three models that must be balanced with each other in the analysis phase.

Show answer
Functional (use case, activity), structural (CRC, class, object) and behavioral (sequence, communication, state machine) models.

Each model is verified within itself, then the three models are balanced in pairs: functional-structural, functional-behavioral, structural-behavioral. If a change is made to one model, the others are updated too.

Verification: Conceptual questions; the walkthrough roles, model balancing rules and layer definitions were checked against the standard definitions (the Dennis, Wixom and Tegarden framework). The gaps in the 'find the inconsistency' questions were checked by hand on the model fragments on the page. There are no numeric answers.

Review card

Verification: are we building the model right? Validation: are we building the right system? Walkthrough: team review; find errors, fix later Roles: presenter (explains), recorder/scribe (writes), maintenance oracle (maintenance, standards) Managers do not attend; the model is evaluated, not the person Functional ↔ structural: nouns in descriptions = classes/attributes; every class in a use case Functional ↔ behavioral: a sequence for every use case; messages = description steps Structural ↔ behavioral: every message = an operation of the receiver; state machine event = operation Activity actions ↔ use case steps; object node ↔ class Factoring: abstraction (superclass) / refinement (subclass) Partition / collaboration: classes working together → subsystem Package diagram: packages + dashed arrow dependency Layers: foundation, problem domain, data management, HCI, physical architecture