230 likes | 397 Views
Ch5: Software Specification. Finite State Machines (FSMs). Consist of: Use of FSMs:. FSMs (contd..). Graphically, -. q. 1. a. a. b. q. q. 2. 0. c. b. q. 3. FSM example: A lamp. Push switch. Off. On. Push switch. FSM example: A plant control system. High-pressure alarm.
E N D
Finite State Machines (FSMs) • Consist of: • Use of FSMs:
FSMs (contd..) Graphically, - q 1 a a b q q 2 0 c b q 3
FSM example: A lamp Push switch Off On Push switch
FSM example: A plant control system High-pressure alarm High-temperature alarm On Off Restart
FSM example: A refinement of plant control system Temperature signal Pressure signal Pressure Pressure action action Successful Unsuccessful recovery recovery Normal Off Normal Off Successful Unsuccessful recovery recovery Temperature signal Pressure signal Temperature action
Classes of FSMs • Deterministic/non deterministic: • FSMs as recognizers: • FSMs as transducers:
FSMs as recognizers e g i q q q q 1 2 3 4 n b q q 0 f e d q q 5 6 n
q1 q2 q3 q4 q5 q6 q7 q8 qf q0 FSMs as recognizers (contd..) e a r r d b h i r t w e o What are the strings accepted by this FSM?
Limitations of FSMs • Finite memory • State explosion
Limitations of FSMs (contd..) In the composite FSM, a state is given by a 3-tuple: State of the storage: State of the producer: State of the consumer: Initial state: Total number of states in the composite FSM:
Limitations of FSM (contd..) The resulting FSM
FSMs summary • Simple and widely used: • Most software can be modeled using FSMs • FSMs may become complex: • FSMs can be composed to create new FSMs
UML diagrams • Use case diagrams • Sequence diagrams • Collaboration diagrams
Use case diagrams • Show all the possible functionality • Do not describe any details • Used during requirements analysis
Components of use case diagrams (contd..) Association
Uses of use case diagrams • Determining features (requirements): • Communicating with clients: • Generating test cases:
Suggestions for designing good use cases • Choose a good name: • Show a complete and completable behavior: • Show inverse use cases if applicable: • Limit a use case to one behavior/function: • Write the use cases from the actor’s point of view:
Use case diagrams – Example #1 Consider an airline reservation system. A customer can use this system to either make or cancel a reservation. The system obtains flight information such as the availability of the flights from an external flight database system. During the process of making a reservation, the system may be required to obtain credit card authorization from the credit card system. Every day, the system compiles a list of passengers with reservations on each flight is forwarded to the security personnel.
Use case diagrams – Example #1 Use case Security Personnel Reservation System CreditCard System Compile List Communication Actor Make Reservation External Flight Database Customer Cancel Reservation