Beruflich Dokumente
Kultur Dokumente
Introduction(I)
Activity diagrams describe procedural logic, business process, and workflow. Activity diagrams focus on the action sequence of execution and the conditions that trigger or guard those actions. Activity diagrams focus on the activitys internal actions, not on the external interfaces
Introduction(II)
Activity diagrams have similarities to flowcharts
But flowcharts notation does not support parallel behavior. Business managers may prefer activity diagrams over flowcharts, because they are more understandable for non-technical people.
An activity diagram is a special case of state chart diagram in which states are actions.
Introduction(III)
An activity diagram shows flow control within a system.
Handle Incident Document Incident Archive Incident
Basic ElementsAction(I)
Action in Activity Diagram Elements official UML name is action state. Distinction between action and activity
Action state refers to it as action Use term activity only refer to the whole task being modeled by the activity diagram
Basic ElementsAction(II)
The rounded rectangle represents an action that occurs. E.g., Customer calls ticket office :
Customer Calls Ticket Office
The initial state shows the starting point for the action sequence within an activity diagram.
Action 2
Incorrect rendering of an initial state within an activity diagram. The initial state can indicate only ONE action
Basic ElementsFlow/edge
The arrow on the diagram. There is a subtle difference between flows and edges.
Decision
A diamond with one flow entering and several leaving.
[Drink contains alcohol]
Merge
A diamond with several flows entering and one leaving. Tell Customer To
Order A Non Alcoholic Drink Make Sure Customer Is At least 21 Years Old
[Drink contains
alcohol] Customer Orders Drink
[else]
Synch
A thick, solid line, allowing two or more action sequences to proceed in parallel
Action 1
Fork
Synch with one flow going into it and several leaving it. Denotes the beginning of parallel actions.
Verify Order Products Are In Stock
Receive Order
Join
Synch with several flows entering and one leaving. All incoming flows must reach it before processing may continue. This denotes the end of parallel processing.
Verify Order Products Are In Stock Accept Order Verify Customer Has Available Credit
Signals
An Activity diagram can have a clearly defined start point, which corresponds to an invocation of a program or routine. Activity diagram can also show response to signals. A time signal occurs because of the passage of time (for example, each month end might trigger a signal.) A real time signal indicates that the activity receives an event from an outside process. The activity listens for those signals, and the diagram defines how the activity reacts.
Signals
Activity diagrams can show signals sent or received For example, we can send a message and then wait for a reply before we can continue. Basically, the signals are flow triggers.
Send signal
Time signal
Accept signal
Flow
Connection between 2 actions Simple flow - arrow
- from a node to another
Flows (cont.)
Flow with objects
Flows (cont.)
Decision flows
-labeled
Connectors
- does the same job as a simple arrow
Tokens
Tokens flow through the diagrams: The initial node creates a token, executes, passes the token to the next Fork produces a token on each of its outward flows. On a join, as each inbound token arrives, nothing happens until all the tokens appear at the join; then a token is produced on the outward flow.
Join Specification
Boolean expression using the names of the incoming edges to specify the conditions under which the join will emit a token. Evaluated whenever a new token is offered on any incoming edge. Default - "and
Expansion Region
Structured activity region that executes multiple times corresponding to elements of an input collection.
Example: The hotels may be booked independently and concurrently with each other and with booking the flight.
Advanced Notation
Conditional threads
Conditional threads
One of a set of concurrent threads is conditional. Example: Frequent-flyer member? Award the passenger frequent flyer miles.
Partitions
The contents of an activity diagram may be organized into partitions Does not have a formal semantic interpretation May represent organizational unit
Dimensional Partition
Dimensional Partition
Dimensional Partition
Activity diagram with partitions focuses on how you divide responsibilities onto classes The sequence diagram helps you understand how objects interact and in what sequence.
Specification standards
No need for documenting the Activity diagrams beyond diagram itself. However, most UML tools provide in-built documentation capturing and printing capabilities for the Activity diagram and its elements.
Introduction to Observer
A Gang of Four design pattern, one of the patterns discussed in Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Observer defines a one-to-many or many-to-many dependency between objects. When the state of one object changes, then all the other objects that are dependent on that object are updated automatically. Used for event handling where consistency between objects is necessary, e.g. Swing Framework for GUI development.
General Example
Suppose you have some data that can be displayed by a table, a bar graph or a pie chart. Changes to the underlying data should be reflected in all three of the displays This is where the Observer Design Pattern comes in handy.
Area that is likely to change is mixed with area that is not likely to change update() calls are coded to concrete objects, not types Need to change code if the subscribers change
Generalized Structure
ConcreteSubject
Implements the Subject interface Maintains direct or indirect references to one or more ConcreteObservers Keeps track of its own state When its state changes it sends a notification to all of its Observers by calling their update() methods
ConcreteObserver
This is the actual object that is observing the state of the ConcreteSubject. The state that it maintains should always be consistent with the state of its Subject. Implements update() method.
General Implementation
Subjects can track Observers through ArrayLists or other data structures. Observers can track multiple Subjects and get different data from each. Pull model uses an update method that takes a reference to Subject as a parameter. The Subject should trigger updates when its state changes.
General Implementation
Methods that change state may call a stateChanged() method:
Implementation in Java
Java has built-in support for Observer
java.util.Observable class can be extended by a Subject java.util.Observer interface can be implemented by a class that wants to observe a Subject
Methods in java.util.Observable
Observable() setChanged()
Creates an Observable object (Subject) with no Observers initially Indicates that this Subject has changed in some way. Returns True if the setChanged() method has been called more recently than the clearChanged() method. Returns False if otherwise. Indicates that this object is done notifying all of its observers of its most recent changes. It is called automatically by notifyObservers() method Returns the number of objects that are Observing this Subject.
hasChanged()
clearChanged()
countObservers()
deleteObserver(Observer o) / deleteObservers()
Removes the passed Observer object or all of the Observer objects respectively from the list of Observers kept by the Subject
Methods in java.util.Observer
update(Observable o, Object arg)
Called when the Subject has changed. o is the Subject in question, and arg is an argument that can be passed to tell the Observer which attribute of the Subject has changed.
Cant compose another class that has an Observable since setChanged() is protected
Cascading notifications if Observers update their own clients or if they can also make changes to the Subject Repeated notifications when sequences of changes occur. Dangling references to Subjects or Observers when either type are manually deleted in non-garbage collected environments. Need to notify Observers when Subjects are deleted and vice-versa. Subject state must be self-consistent before calling notify(), especially with pull model. Careful not to push irrelevant information on observers with push model. If update() fails, the Observer wont know that it missed potentially important information
Trouble Spots
Books: Freeman, Freeman, Sierra, and Bates, Head First Design Patterns,OReilly 2004, p. 73 Gamma, Helm, Johnson, and Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley 1995. Websites: Activity Diagrams: http://www.agilemodeling.com/artifacts/activityDiagram.htm http://computersciencesource.wordpress.com/2010/03/15/software-engineering-activity-diagrams/ http://www.cse.unt.edu/~rgoodrum/Teaching/2009/fall/4910/website%20files/handouts/umlbasicsp2_actdg.pdf http://www.devx.com/ibm/Article/21615 http://edutechwiki.unige.ch/en/UML_activity_diagram http://www.sa-depot.com/?p=158 http://sourcemaking.com/uml/modeling-business-systems/external-view/activity-diagrams http://www.uml-diagrams.org/activity-diagrams.html Observer: http://www.blackwasp.co.uk/Observer.aspx http://www.cs.clemson.edu/~malloy/courses/patterns/observer.html http://www.codeproject.com/KB/architecture/Observer_Design_Pattern.aspx http://java.dzone.com/articles/observerpattern?utm_source=am6_feedtweet&utm_medium=twitter&utm_campaign=toya256ForRSS http://www.patterndepot.com/put/8/observer.pdf http://sourcemaking.com/design_patterns/observer http://userpages.umbc.edu/~tarr/dp/lectures/Observer.pdf http://en.wikibooks.org/wiki/Java_Programming/Design_Patterns#Observer http://www.wohnklo.de/patterns/observer.html
References