Section 5 · VeriSIM: Comprehending Software Designs
On this page 7 headings
Learning goals: Explain the automated-door requirements; connect class and sequence diagrams; trace lock state precisely across events.
VeriSIM reinforces modelling by asking learners to simulate a realistic scenario and trace precisely when state changes occur.
What Is VeriSIM? Simulating a Design
VeriSIM means 'Verifying Designs by Simulating Scenarios'. The learning environment helps students develop an integrated understanding of class diagrams and sequence diagrams. Instead of merely memorising UML symbols, students examine how the operations and data described by the classes produce the messages and state changes shown in a scenario.
The lecture uses an automated door-locking example. The focus is the locked/unlocked state after passcode verification.
Automated Door Locking: Requirements
1. If the passcode hasn’t been set yet, the user can register and enter a required passcode. 2. When the user chooses the lock option and enters the correct passcode, the door should lock; if the passcode is incorrect, the door remains unlocked. 3. When the user chooses the unlock option and enters the correct passcode, the door should unlock; if the passcode is incorrect, the door remains locked.
The user interface and keypad are only a way to express the request. The lecture is checking a simple logical rule: authentication affects whether the lock state changes. A request to Unlock must not be confused with physically opening the door; similarly Lock does not mean the door must swing shut.
Four Smart Door Outcomes
The four cases are easier to understand if you start with the initial state. Starting unlocked: a correct Lock request changes the state to locked; an incorrect Lock request leaves it unlocked. Starting locked: a correct Unlock request changes it to unlocked; an incorrect Unlock request leaves it locked.
A very common mistake is to focus only on the words 'correct' or 'incorrect' without looking at the initial state. An incorrect passcode does not always mean 'locked'; it means 'unchanged'. Thus the system can remain unlocked after an incorrect attempt to lock it. This distinction is important in both state tracing and scenario-based exam questions.
Key rule: Wrong PIN means *unchanged*, not necessarily *locked*.
VeriSIM: Class Diagram and Sequence Diagram Work Together
Classes: Door (lock: bool; lock(), unlock()), Controller (optionSelected; setOption, register, lock, unlock, resetPasscode, inputPasscode), Passcode (passcode; setPasscode, getPasscode, checkPasscode).
Unlocking sequence: user selects Unlock → controller asks for the passcode → user enters it → controller calls checkPasscode → if true, Door.unlock() and “Door Unlocked”; if false, Door.lock() and “Incorrect Passcode”.
Practice: Name the class owning `unlock()`, then show when it is called.
VeriSIM Design Tracing: Locked to Unlocked
Design tracing follows how internal state changes as events occur. In the lecture's correct-passcode scenario, the door starts locked and the registered system passcode is 1234. Initially `optionSelected = null`, `userInputPasscode = null`, and `lock = true`. Event E1 selects Unlock; this changes only `optionSelected`. Event E2 enters the correct `1234`; this updates `userInputPasscode`. Finally E3 performs the Unlock operation, changing `lock` from `true` to `false`.
The transitions correspond to messages in the sequence diagram; the variables in the states come from the class diagram. Constructing such state diagrams builds an integrated understanding of class and sequence diagrams. After E2 the passcode matches, but lock remains true until E3 executes.
Vital check: After E2, entered PIN matches, but `lock` is still `true`.
VeriSIM Learning Stages and Feedback
The VeriSIM learning sequence begins with an Introduction. In Problem Understanding, the learner examines system requirements and supporting class and sequence diagrams. In Design Tracing, the learner works through scenario challenges to predict and verify the changing values of system state. In Reflection, the learner explains what the exercise revealed about the design.
The lecture indicates that challenges can be attempted in different orders. Reflection helps connect the diagrams to real behaviour: what changed, which event caused it, and which class or method was responsible? This is why active scenario tracing is more valuable than only looking at a static diagram and memorising its name.
Quick revision and self-check
Question: If an incorrect PIN is entered, what happens?
Answer: The current lock state remains unchanged.
Question: Why does State 3 still show lock=true?
Answer: The unlock operation (E3) has not happened yet.
Question: What two UML views are integrated by VeriSIM?
Answer: Class diagrams and sequence diagrams.
