Synthesis of State Machines from Multiple Interrelated Scenarios Using Dependency Diagrams
Total Page:16
File Type:pdf, Size:1020Kb
Synthesis of State Machines from Multiple Interrelated Scenarios Using Dependency Diagrams Simona VASILACHE Department of Computer Science, University of Tsukuba Tsukuba, Ibaraki 305-8573, Japan and Jiro TANAKA Department of Computer Science, University of Tsukuba Tsukuba, Ibaraki 305-8573, Japan ABSTRACT They can be used not only for behavioral requirements specifications, but also for detailed design models close to Requirements specification is one of the most important phases implementation [4]. in developing a software application. In defining the behavior While scenarios represent a single trace of behavior of a of a system, requirements specifications make use of a number complete set of objects, state machines represent the complete of scenarios that are interrelated in many ways. Most of the behavior of a single object. Together, they provide an current approaches, even though giving directions on how to orthogonal view of a system. By transforming scenarios into translate them into state machines, treat each scenario state machines, we can take advantage of the benefits offered separately. Because different relationships between scenarios by both of these concepts. result in different state machines, we believe it is significant to Scenarios are generally not independent of each other; various emphasize and represent these relationships. In order to relationships and dependencies connect them. We make a illustrate them we propose a new type of diagrams named classification of these relationships and in order to represent dependency diagrams. We offer a set of rules and steps for the them we propose a new type of diagrams. We call these synthesis of state machines from multiple inter-related diagrams dependency diagrams. scenarios, based on the initial scenarios and on the newly Based on these dependency diagrams and on the given introduced dependency diagrams, as a means to describe the scenarios, we give rules and steps of synthesis of state requirements specifications and to offer support during the machines from multiple interrelated scenarios. We will design and implementation phases of developing a system. describe in this paper the newly introduced diagrams and our method of synthesis. Keywords: requirements specification, dynamic modeling, The remainder of the paper is organized as follows: section 2 scenarios, state machines. offers an overview of scenarios and state machines. In section 3 we make a classification of the relationships that can exist between various scenarios and we describe the dependency 1. INTRODUCTION diagrams. Section 4 illustrates the synthesis of state machines from multiple scenarios. Section 5 discusses several issues, Requirements analysis represents a crucial phase in the while section 6 deals with related work and is followed by software development process. The main task of the conclusions in section 7. requirements analysis is to generate specifications that describe the behavior of a system unambiguously, consistently and completely [1]. Several object-oriented methodologies and 2. SEQUENCE DIAGRAMS AND STATE MACHINE notations (like OMT [2], UML [23]) make use of scenarios as a DIAGRAMS means of capturing requirements specifications, as well as a means of communication between users and software Scenarios as sequence diagrams developers. A scenario is a sequence of events that occurs In UML, scenarios are represented as sequence diagrams. during one particular execution of a system [1], it is one Sequence diagrams illustrate how objects interact with each particular “story” of using a system. other. They focus on showing the sequence of messages sent During the recent years, scenarios have gained considerable between objects, that is the interaction between objects from a popularity. However, we believe that they have not yet temporal point of view. received the attention they actually deserve and they have not Sequence diagrams have two axes: the vertical axis shows time been used up to their entire potential. Their usefulness lies not and the horizontal axis shows a set of objects. An object is only in the ability to capture requirements, but also in their represented by a rectangle and a vertical bar called the object's applicability when used in conjunction with other models. We lifeline. Objects communicate by exchanging messages, specifically refer to what is called "behavior models", that is represented by horizontal arrows drawn from the message models that describe the behavior of a system. sender to the message recipient. The message sending order in State machines (particularly statecharts, originally introduced a sequence diagram is indicated by the position of the message by D. Harel [3]), represent a compact and elegant way of on the vertical axis. describing the aspects concerning the behavior of a system. State machine diagrams - time dependencies; State machine diagrams represent state machines from the - cause-effect dependencies; perspective of states and transitions. The representation used in - generalization dependencies. UML’s state diagrams is inspired from Harel's statecharts [3]. State diagrams describe what states an object can have during A time dependency signifies the fact that one scenario has to be its life cycle and the behavior in those states, along with what executed at an earlier/later moment in time than another events cause the states to change. All objects have a state; the scenario. Only after the scenario that has to be executed first state is a result of previous activities performed by the object. has finished its transitions, the second one can start its An object changes state when something happens, which is execution. It can also mean that two (or more) scenarios must called an event. be executed at the same time. For instance, as described above, State diagrams may have a starting point and several end points. a user must first prepare a card and only then (s)he can perform A state is represented as a rounded rectangle; between states transactions through the ATM. Therefore, the scenario of there are state transitions, shown as a line with an arrow from creating a card precedes the scenario of withdrawing cash and one state to another. The state transitions may be labeled with the two scenarios are in a time dependency. the event causing the state transition. When the event happens, A cause-effect dependency reflects the fact that the execution the transition from one state to another is performed (the of a scenario can take place only the moment certain conditions transition is "triggered"). This means that the system leaves its (established in another scenario) become valid. For example, an current state, initiates the actions specified for the transition ATM can satisfy the user’s request for withdrawing cash only and enters a new state. A state transition normally has an event if it has been previously provided with a number of bills/coins. attached to it, but not necessarily. If an event is attached to a The scenario of withdrawing cash depends on the scenario of state transition, the transition will be performed when the event the ATM machine being ”loaded” with a sufficient amount of occurs. If a state transition does not have an event specified, the cash (considered to cover the maximum amount that could be attached state will change when the internal actions in the withdrawn during a whole day). The condition “being able to source state are executed. Therefore, when all the actions in a provide enough cash” is established in a different scenario from state are performed, a transition without an event will the one where the transaction itself takes place. automatically be triggered. A generalization dependency emerges when one scenario is a State machine diagrams have proved their usefulness in the constituent part of another one or a variant of it. As a rough dynamic description of the behavior of a system. Moreover, example, we can consider that the scenario of withdrawing cash they can be used for generating code directly from them, since is very similar to the scenario of depositing money. They can each of them describes the complete behavior of one object. be generalized under one scenario, ”cash operations”, for example, where we have 2 variants with slight differences between them (in the case of deposit: the user selects ”deposit” 3. RELATIONSHIPS BETWEEN SCENARIOS; and inserts the money in the special slot in the ATM; in the DEPENDENCY DIAGRAMS case of withdrawal: the user selects ”withdrawal” and the money is ejected through the same slot). Classification of relationships One could argue that time dependencies and cause-effect Since a scenario represents a particular “story” of the execution dependencies are equivalent, but we believe that it is important of a system, in order to describe a system completely, we need to emphasize when the dependency arises from a specific time to know all the possible scenarios. Depending on the sequence (like having to insert the card and password first, and application, the number of scenarios varies; however small the only after that being able to perform a transaction) and when a number of all possible scenarios is, relationships, dependencies dependency arises from certain conditions that are not exist between them. Sometimes, one scenario follows another explicitly time-related (at least, not necessarily). As we scenario or is conditioned by another one. Many times the described above, a user could withdraw cash only if the ATM order and the timing of their execution are not arbitrary. has been provided with bills and coins. In this case, we believe it is not so important to emphasize the time sequence To illustrate our point, let us consider a simplified example of (supplying bills first and then being able to satisfy the user’s an ATM (Automated Teller Machine). A consortium of banks request for cash), as it is important to emphasize that having the shares the ATMs. Each ATM accepts a cash card, interacts bills is a necessary condition, which if it is not met, the with the user, communicates with the central system to carry operation cannot take place.