tailieunhanh - Software design and architecture (Lecture Notes) – Chapter 26

When an analyst is attempting to understand the underlying domain of a problem, he or she must consider both structural and behavioral aspects of the problem. One of the primary differences between the class diagrams and the interaction diagrams, besides the obvious difference that one describes structure and the other behavior, is that the modeling focus on the class diagram is at the class level, while the interaction diagrams focus on the object level. | Lecture Notes Lecture 26 – STATE MACHINE DIAGRAM INTERACTION DIAGRAMS When an analyst is attempting to understand the underlying domain of a problem, he or she must consider both structural and behavioral aspects of the problem. One of the primary differences between the class diagrams and the interaction diagrams, besides the obvious difference that one describes structure and the other behavior, is that the modeling focus on the class diagram is at the class level, while the interaction diagrams focus on the object level. STATE MACHINE DIAGRAM Some of the classes in class diagrams represent a set of objects that are quite dynamic in that they pass through a variety of states over the course of their existence. For example, a patient can change over time from being “new” to “current,”“former,” and so on, based on his or her status with the doctor’s office. A behavioral state machine is a dynamic model that shows the different states that a single object passes through during its life in response to events, along with its responses and actions. States, Events, Transitions, Actions, and Activities The state of an object is defined by the value of its attributes and its relationships with other objects at a particular point in time. For example, a patient might have a state of “new” or “current” or “former.” The attributes or properties of an object affect the state that it is in; however, not all attributes or attribute changes will make a difference. For example, think about a patient’s address. Those attributes make very little difference as to changes in a patient’s state. However, if states were based on a patient’s geographic location (., intown patients were treated differently than out-of-town patients), changes to the patient’s address would influence state changes. An event is something that takes place at a certain point in time and changes a value(s) that describes an object, which, in turn, changes the object’s state. It can be a designated condition becoming true, the receipt of the call for a method by an object, or the passage of a designated period of time. The state of the object determines exactly what the response will be. A transition is a relationship that represents the movement of an object from one state to another state. Some transitions will have a guard condition. A guard condition is a Boolean expression that includes attribute values, which allows a transition to occur only if the condition is true. An object typically moves from one state to another based on the outcome of an action that is triggered by an event. An action is an atomic, non-decomposable process than cannot be interrupted. From a practical perspective, actions take zero time, and they are associated with a transition. In contrast, an activity is a non-atomic, decomposable process that can be interrupted. Activities take a long period of time to complete, they can be started and stopped by an action, and they are associated with states.