Software model design foundation - behavior

zhaozj2021-02-16  86

1.2 behavior

1.2.1 Interaction (Interaction)

Interaction is a collection of messages in collaboration, which are swapped by associated roles by the class element role. When collaboration is running, an object being constrained by a class character is swapped by an associated role constraint. Interaction can be modeled to the operation, use case, or other behavior entity.

The message is a single communication between two objects, from the sender to the recipient's control flow. The message has the parameters used to pass the value of the object.

Message sequences can be understood from different directions. You can get two maps: sequence map (who first who is first) and collaborative map (who is interactive).

The message sequence as above is important, mainly by sequential diagrams and collaboration diagrams to associate the source code.

How to understand how to interact, as a behavior, interaction is a series of messages for communication between a set of objects (such as operation). First, interacting between a set of objects; secondly, the exchange is to complete a task; finally, interacting a series of messaging.

For example, the farmer wants to calculate the birth of the sheep, he first knows to ask those people to ask; second, he also knows what to ask; finally, he asked (some feeding staff) have some problems. When this interaction is over, he calculates the number of sheep (may be carried out in the interaction of the message).

Understand from life, interacting a message, and in UML, interacting is a collection of these information exchange processes (behavior).

Interaction representation in sequence diagrams, collaborative drawings, and active diagrams.

1.2.2 State Machine (State Machine)

The state machine is a state and transformation map, which describes the response of the class element instance on the event. The state machine can be attached to a certain type element (class or usage), and can also be attached to collaboration and method, and the element of the state machine is referred to as a state machine.

The execution of the state machine: The status machine handles an event at a certain event and must complete the result of this event before processing additional events.

Semantic description (more oysters): There is an activity of one or more state machines at any time. If a state is active, the conversion of leaving this status (which is excited) may be excited, causing an action to execute, and activate the status of another state or in the initial state position (the next state is in the initial state) .

The sub-state of the state machine (also oxidant): The structure of the state machine and the state of the state machine can apply constraints on the state of concurrent activity. That is, if a sequential state, only one direct mutually exclusive state must be active; and a concurrent composition state is active, each direct subsist must be active.

Regarding the semantics of the state machine, I will explain the following, but how do it understand?

The state machine is a state sequence that describes the object of the object of its (state machine) in its (object) life period, and their response to those events. Explain a few nouns:

1. State: Refers to a condition or condition in the life of the object, during which the object will meet certain conditions, perform some activities or wait for some events.

2. Event (event) is a specifications for a meaningful thing to occupy a certain location in time and space. In the state machine, an event is an excitation generation, and the excitation can trigger a state transition.

3. Transition is a relationship between two states, indicating a certain action executed in the first state, and enters the second state when a particular event or a particular condition satisfies.

A activity (Activity) is the non-atomic execution made in the state machine.

A action (action) is an executable atomic calculation that causes the model state change or the return of the value. Here are the concepts:

The state machine is very simple, saying a most common example, we go home from get off work, people (if it is me error.cao) is an object, let's examine a few states:

1. When you get off work, you can get home (not overtime). 2. Start the elevator. 3. Go downstairs. (I found no home key, get upstairs.) 4. Go on the floor. 4. Go to the bus and wait. 5. Take the bus to the vegetable farm. 6. Buy food 7. Go home

So what? 1. Get off work is here (ready to get off work). 2. Elevator to (on the elevator) 3. Elevator to downstairs (lower elevator) 3. Discover no home key (to get the key). 4. You have to take yourself to the bus (get on the bus). 5. Bus to the station (get off). 6. Suddenly remembers no dishes in the house (go to buy vegetables).

So what is the conversion: There is an event (find no home key), the status one (to the downstairs) is converted to the state 2 (upper floor), of course this transformation is the behavior of the object (Error.cao). At this point, the concept of the initiality and the final state: the initiality and the finalization are not targeted, but for the object, the state is not an initiality, the initiality is time; the final state is natural Not a state of two (upper floor), but return home. So what is the state of this conversion? Is it a source state of this conversion? It is the target state of the conversion (Target State).

I don't quite agree with this statement. It can only be said that it is implicitly triggered, for example, the above event two, we can not express it is an event, but from state two (starting elevator) to the status Three (downstairs) is a hiddenly trigger, it has any incidents, of course, it is just that we have not considered (these events can be ignored).

There is still terms, called guard conditions, what is the conditioning conditions? Look at the event one (getting off work), we must define a time, then tell you by the clock (it is time to take the time and getting off hours time) time, ok, time to get off work (event production) The event is generated, and the object is transformed.

Of course, each state itself contains the following: (parentheses indicating that this state is not)

Name: The name of the name, the state.

Enter / Exit Action: One operation of the object itself, such as a state in the elevator, where we enter the elevator and out of the elevator is the state --- in the elevator --- enter / exit action.

Internal conversion: For example, when we go to the elevator, we found that the key did not bring. At this time, we don't have to wait for the elevator. There is no event trigger. We will take the key on the state of getting off work, for the object itself, before and after The fundamental state is different, one is a key, one is no key.

(Sub-state): If we describe that the object speaks in the elevator, the state is the status of the object state - in the elevator --- state.

(Delayed event): An event that is not generated now, the event is an event that is only after a while.

Half a day, what is the state machine? Objects have experienced a state in response to a series of events from the initiality to the term, while the response to the event. First, it is not this process, but it describes this process, which is the behavior of the object in this series of processes.

The above is what we do every day, this is not a use case, but it can be said that it is an object multiple use cases (a use case may be described only more than such a state and its response). If we say that the UML chart is clear, everyone will suddenly be clear, because our goal is clear, it is to develop our customers' needs, we use UML to model the system, the end result of UML is a variety of pictures The form is to expressed the relationship between the various types, and we can prepare software code by expressing the classified relationship.

1. 3 groups

1.3.1 package (package)

The definition of the package: It is used to organize the general mechanism to group elements.

The package is in collaboration in understanding the components, the component is an element that makes up a thing, and our defined package is a component of a component's abstraction, which is to divide the class yuan into a group (can also be referred to as a module). ). My original initial idea is Package = Component (s), and then there is no such simple, package = component (s) rule, this rule is not provisions, is an abstraction of the ideology on the component, and this abstraction is our bag. Definition.

The package is mainly including other elements, such as classes, interfaces, components, nodes, collaboration, usage examples, and diagrams, of course, can also include other packages.

转载请注明原文地址:https://www.9cbs.com/read-11890.html

New Post(0)