Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to UML Todd Bacastow Penn State University Geography 583 Geospatial System Analysis & Design.

Similar presentations


Presentation on theme: "Introduction to UML Todd Bacastow Penn State University Geography 583 Geospatial System Analysis & Design."— Presentation transcript:

1 Introduction to UML Todd Bacastow Penn State University Geography 583 Geospatial System Analysis & Design

2 What is the UML? Unified Modeling Language
It is a modeling language, not a process In 1996, work on the UML was begun by Rational. Where to Find Out More

3 UML Diagrams Class Diagrams Use Case Diagrams Collaboration Diagrams
Sequence Diagrams Package Diagrams Component Diagrams Deployment Diagrams Activity Diagrams State Diagrams Types of UML Diagrams

4 Class Diagrams Are the most fundamental UML Diagram.
Describe the classes in the system, and the static relationships between classes. Class diagrams are used during Analysis, Design and Development. Class Diagrams Class diagrams that appear during the Analysis phase generally describe user interface and related classes. In UML Distilled read the description of class diagram perspectives located on page 65. Most of the class diagrams will be generated during Design. Some may be generated during early Development, and classes will often be modified during Development. Static relationships are relationships between classes (which can be thought of as object templates).

5 UML Class Diagram 1 1..* 1 0..1 1 What is a Class Diagram? Customer
Rental Invoice Rental Item 1..* 1 0..1 1 What is a Class Diagram? Checkout Screen DVD Movie VHS Movie Video Game This class diagram shows examples of associations, aggregations, and generalizations. In general, associations describe the relationships between classes or objects. They start as simple connectors, to show that some relationship exists. As design progress the natures of the relationships become clearer, and the associations are modified to reflect the new knowledge. For example, direction and cardinality are usually added later in design. The diagram above shows a generalization relationship between several kinds of objects. Generalization means here that the specializations of Rentable Item are fully consistent with Rentable Item and may be used wherever Rentable Item is allowed.

6 UML Class Diagram 1 1..* 1 0..1 What is a Class Diagram? Multiplicity
Customer 1 Simple Aggregation Class Abstract Class Rental Invoice Rental Item {abstract} 1..* 1 0..1 Composition (Dependency) Simple Association Generalization What is a Class Diagram? Checkout Screen DVD Movie VHS Movie Video Game

7 -- can optionally be described here.
Parts of a Class Classes can have four parts Name Attributes Operations Responsibilities Classes can show visibility and types. All parts but the Name are optional. MyClassName +SomePublicAttribute : SomeType -SomePrivateAttribute : SomeType #SomeProtectedAttribute : SomeType +ClassMethodOne() +ClassMethodTwo() Responsibilities -- can optionally be described here. The Parts of a Class An individual class is shown on the diagram as a box with up to four sections. The first section shows the name of the class. Names should be nouns. Typically the first letter of every word in a name is capitalized. Attributes represent the state of the object or what the object knows. Operators represent the behavior of an object or what the object does. Responsibilities are optional. A Responsibility is a contract or an obligation of the class. They are normally only used in analysis and early in the design phase to describe what a class should do without describing how it should do it. The + sign indicates that an attribute or operation is public or visible to all other objects or operations in the system. The - sign indicates that an attribute or operation is private or hidden from any objects or operations other than those objects also of the current class. The # sign indicates that an attribute or operation is protected or visible only to members of the same class or members that are specialization's of (or derived from) that class.

8 Object Diagrams Described
An Object is an instance of a class. Object names are underlined. Object diagrams are similar to class diagrams. Many of the same notations are used. Object diagrams capture instances of classes, and allow the dynamic relationships to be shown. ThisOne : MyClassName +SomePublicAttribute : SomeType -SomePrivateAttribute : SomeType #SomeProtectedAttribute : SomeType +ClassMethodOne() +ClassMethodTwo() Object Diagrams Described Object diagrams have a very similar appearance to class diagrams (see next slide), but are more specific. It is very important to make sure the syntax rules for writing the names of classes and objects are followed. Otherwise, confusion is sure to result. Object diagrams are useful when information about the dynamic relationships between classes must be captured. Dynamic relations are between instances (of classes). If a particular person (Bob) rents a particular movie (Casablanca), there is a dynamic relationship between Bob:Person, and Casablanca: Movie. Compare to static relationships (defined on the previous slide).

9 Class and Object Diagrams
Class Name Association Name Customer Rental Item +id:integer Rents 0..n +id:integer +name:string +released:date 0..1 Class Diagram Attributes Object Name Joe: Customer Casablanca: Movie Class Diagrams and Object Diagrams +id:1667 +id:22340 Note that the object diagram is much more specific. Values are provided for data. The relationship is less abstract, because it refers to the relationship between two instances (here, ‘Joe’ and ‘Casablanca’), and not the theoretical relationship between classes. The UML specification requires that object names be underlined. Objects do not need to be named, but if an object does not have a name, the name of its class must be preceded with a colon. This makes clear that the name represents a class and not an object. In the diagram above, “:Customer” could also be used. Class names are also not required; if the class name is not provided, there should not be a colon. In the diagram above, ‘Joe’ could also be used. Obviously, each object should have either a name or a class name. Be careful when simplifying diagrams by removing names -- ensure that you have not removed vital information. If ‘Joe’ could be an instance of any of a number of related classes, it may be important to show which class it is. The idea is to strike the right balance between a diagram that captures the needed information, and one that’s not so cluttered the eye cannot follow the concepts. +name:Joe Smith +released:1942 Object Diagram

10 Use Cases Describe interactions between users and computer systems (both called actors) . Capture user-visible functions. Achieve discrete measurable goals. Are typically used during Analysis and Design. What is a Use Case? A use case model is important for visually representing a system, but equally important is the text that supports the use case model, called the Use Case Report. The elements of the Use Case Report will be discussed in later slides. A use case is initiated by an actor to perform a required task. Most of the time, an actor is a person, but that doesn’t have to be the case. Sometimes, an actor can be another computer system -- for example, when an external system requires a roll-up report for processing, one might view that system as an actor, and the generation of that roll-up report as a use case.

11 Use Case Diagram for the Movie Store
Telephone Customer In-Store Clerk Identify Movie Open Account Return Movie Review Account Status Actor Use Case Use Case Diagram for the Movie Store An actor is someone or something that initiates use cases. It is stereotyped from a class. A use case is a sequence of actions performed at the request of an actor. A use case contains all the actions that can occur between an actor-use case pair. In a given scenario, some actions may not occur. A use case contains a set of scenarios that explain various sequences of interactions within it. An association represents a semantic connection between an actor and a use case. Associations are uni-directional; they are the most general of all relationships and the most semantically weak. A stereotype can refine the association. A generalization relationship can show actors that share behavior (perhaps several actors can function in role; that role can also be an actor which defines the common behavior). Diagram Notes: The use cases here are: Identify Movie, Open Account, Return Movie, and Review Account Status. The actors are: Customer and Clerk. The Customer is the parent actor and the In-Store and Telephone Customer are child actors. The child actors inherit some of their characteristics from the parent actor. The Customer can initiate the Identify Movie, Open Account, and Return Movie use cases; the Clerk (or any of its specializations) can initiate any of the use cases. Identify Movie names the movie the customer is looking to rent. The clerk will also need to identify the movie in the movie database or on the shelves in the store. Open Account allows the customer and clerk to establish an account. Return Movie explains that the customer brings the movie back to the store and the clerk puts the movie back in the database as “available” and places the movie on the shelf. Review Account Status is only initiated by the clerk. It allows the clerk to review information not generally available to (or needed by) the customer.

12 What is a Use Case Report?
The Use Case Report provides documentation for the Use Case. A Use Case is not complete without the report. The elements of the Use Case Report are shown on the right. Brief description Precondition Flow of events Main flow Subflows Alternate flows Postcondition Special Requirements Enclosures Diagrams Pictures of the UI What is a Use Case Report? The purpose of a Use Case Report is to describe the flow of events specifically in a way the customer understands. 1. Brief description-should describe the purpose of the use case in a few sentences. The actor that initiates the use case can be documented here. 2. Precondition-a precondition is a constraint on the system or indicates another task or use case that must be completed before beginning the use case being documented. 3. Flow of events-should describe when the use case begins, when it ends, where different actors take part in the flow of events, and the information exchanged. The main flow does not describe how problems are solved or the details of the UI. Each use case should start with, “This use case begins when….” Main flow-is the normal sequence of events for the use case, what normally happens if nothing goes wrong. Subflow-these are optional or parallel sequences, or large segments of a given flow of events that divides the flow of events into different sections. Provide a title for the subflow in your documentation and describe the order of subflows. Alternate flow-an exceptional flow, the “what happens if” part of the main flow. Alternate flows specify variants to the main flow, optional flows, or error cases. Define a condition and the behavior for the alternate flow. 4. Postcondition-defines a constraint on the system when the use case has terminated. 5. Special requirements-non-functional requirements that may influence design. 6. Enclosures-the actual use case diagram, and possibly screen captures of the UI.

13 Collaboration Diagrams
Collaboration diagrams describe interactions and links Focus on exchange of messages between objects Appears during Analysis phase Enhanced during Design phase What is a Collaboration Diagram? Class roles represent roles that object may play within the interaction. Association roles represent roles that links may play within the interaction. Message flows represent messages sent between objects via links. Links transport or implement the delivery of the messages. Another view of the sequence diagram. Collaboration diagram tend to provide the big picture for a scenario, organized around the object links to one another.

14 Collaboration Diagram - Rent Movie
:Rented Items Object 5: add(customer, movies) 1: enter_customer() 8: generateRentalTotal() 3: enter_movies() 2: IsValidCust(CustId) 7: print invoice() :Check-out Manager :Customer :Clerk 4:GetMovieByBarcode() A Collaboration Diagram for the Movie Store The objects in rectangles represent class roles. The links (lines or paths) represent association roles. The arrows between class roles indicate message flows exchanged between objects. The message flows are labeled with both the sequence number of the message and the message that is sent between the class roles. A message triggers an operation in the receiving object. The sequence numbers indicate the sequence of messages within the next higher level of nesting. :Inventory Message

15 What is a Sequence Diagram?
Sequence Diagrams Can be “morphed” from Collaboration Diagrams. Describe interactions between objects arranged in time sequence Focus on objects and classes involved in the scenario and the sequence of messages exchanged Associated with use cases Used heavily during Analysis phase and are enhanced and refined during Design phase What is a Sequence Diagram? Interactions are modeled as exchange of messages. Class roles represent roles that objects may play within the interactions. Lifelines represent the existence of an object over a period of time. Activations represent the time during which an object is performing an operation. Messages represent communication between objects. An object in a sequence diagram is drawn as a rectangle containing the name of the object, underlined. It is easy to read and understand sequence diagram as it looks at a scenario based on time order. This diagram is very useful in the early analysis phase.

16 Sequence Diagram - Rent Movie
:CheckoutMgr Cust:Customer :Inventory :RentedItems :Employee 1: find customer() 2: search (string) Object 3: enter movie() 4: search (string) Message Activation 5: rent (movie) 6: add(Cust, item) A Sequence Diagram Example Lifeline Depicts how the classes within the system work together. The objects at the top represent class roles. The dashed lines that extend from each object represent lifelines. The thin rectangles on the lifelines represent activations. The horizontal arrows between lifelines indicate the messages exchanged between objects. The horizontal arrows are labeled with the message that is sent between the class roles. The message triggers an operation in the receiving object. The objects defined inside the rectangle can be defined in one of the three ways: The object name, the object name and its class, or just the class name (anonymous object) 7: printInvoice() 8: generateRentalTotal()

17 What is a Package Diagram?
Class Package What is a Package Diagram? Packages are a grouping mechanism. A package can contain any other UML construction, including other packages. Packages are useful when producing diagrams that show a larger picture of the system. This package diagram is a fragment of the “Clerk’s User Interface”. The package contains a Customer Data class and a Business System façade package. It also contains a Rental Screen class, and shows that the Rental Screen class depends on the Customer Data class and the Business System façade.

18 What is a Component Diagram?
Interface Dependency What is a Component Diagram? Note A component diagram shows software components, and their dependencies. It is a way of describing the structure of the code. Components are physical entities; they represent the implementation of the logical architecture described by class diagrams, object diagrams, and interaction diagrams. Components can be: Source: some source code; a compilation unit. Meaningful at compile time. Stereotypes such as «file», «page», and «document» can provide additional information about the component’s nature. Binary: object code, or a library file (static or dynamic). Meaningful at link or runtime (this will depend on the specific nature of the component). The stereotype «library» appears here. Executable: executable code; an image. Meaningful at execution time. These at the only variety of component that can have instances (while they are running). The stereotypes «application» and «table» (a database table viewed as a runtime component) are common on this sort of component. Components are types. To show instances of components, one draws a deployment diagram and allocates instances of executable components to the nodes where they run.

19 What is a Deployment Diagram?
Node Communication Association What is a Deployment Diagram? A deployment diagram shows the runtime architecture of the system and the topology (physical architecture) of the system. Each node represents a piece of hardware. A node is a special kind of class; the detailed capabilities of the node can be represented as attributes and/or properties of that class. Nodes are connected by communication associations. These are typically directionless associations that are stereotyped (as in the diagram above) to show what kind of traffic they carry. Components may be placed inside of nodes. This shows that the component runs on the node. A diagram which shows how nodes are connected may not have this level of detail, but a diagram that fully describes a node should. Packages containing components can also be used to simplify the diagram. Objects (instances of classes) can also be drawn in nodes, if appropriate. They can be drawn inside the component that implements them if desired, or they can be drawn standalone (the relationship between an object and the component that implements need not appear in a deployment diagram). A component can be shown to depend on a node, with the stereotype «supports». This indicates that the node supports instances of the component (this is not shown in the diagram above). Because nodes are classes, more complex relationships (including cardinality) are certainly possible. They can be associated in any way that is legal for classes (but some associations may not be useful).

20 Activity Diagram Identify Caller Obtain Name & Address Create Account
Start State Identify Caller Action State Obtain Name & Address Decision Open Account? Current Customer? [no] [no] [yes] Activity Diagrams: Are used in the Analysis and Design phases of ProVision. Can show sequence in use cases and are similar to workflow diagrams. Can show concurrency through parallel flows. Allow multiple start points and conditional branching. Multiple start points can show relationships between different Use Cases. Focus on flows driven by internal processing. Apply to situations where all or most of the events represent the completion of internally-generated actions (the flow of control from activity to activity). Can show how an object changes state at different points in the flow of control. [yes] End State Create Account Diagram Notes: 1. The activity begins when the clerk identifies a caller either over the phone or at the counter. 2. The clerk will ask for identification by name and address. 3. The clerk looks in the database to determine if the customer is a current customer. 4. This is where the decision icon factors into the diagram. If the customer is a current customer, conclude the activity. If the customer is not a current customer, ask the customer if they would like to create an account. 5. The create account is another decision icon. If the customer wishes to create an account, continue with the flow and create an account. If the customer says no, conclude transaction (assuming the Movie Store rents only to account holders).

21 Swimlanes and Fork/Join Points
Customer Manager Walking Clerk Identify Movie Fork Point Place Order Place Order Fill Order Pay Collect Money Swimlanes: Swimlanes organize actions by class. Each swimlane is divided by classes or actors. Each swimlane represents the responsibility of the overall class, the ordering has no significance. Transitions may cross swimlanes. Fork/Join Point: Fork point-this shows where the thread or path divides into two parallel paths. There is no limit to the amount of threads coming out of a fork point. These threads will need to synchronize, which happens at the Join Point. Threads join back together at the join point. The activities below the fork point and above the join point occur in parallel. Pickup Movie Deliver Movie Join Point Diagram Notes: 1. The first action is a Customer checking to see if a movie is available. 2. The Customer orders the movie. 3. The Manager places the order using the movie database. (fork point) 4. The Walking Clerk obtains the order from the back while the customer is paying. (join point) 5. The Walking Clerk delivers the order back to the Manager. 6. The Manager hands the movies to the customer. 7. The Customer picks up the order. 8. The activity terminates.

22 State Diagram Guard Event Transition Action Activity
What is a State Diagram? This is a simple example of a state diagram that describes the video check-out process. UML State Diagrams are very similar to state diagrams seen in other design notations. The diagram contains states and transitions. Each state contains a name, and may also have associated actions. Actions are tasks (typically of a longer duration, and that can be interrupted by events). Actions start when the state is entered. A transition does not occur when an action completes; only an Event (see below) can cause a transition (however, an Event might occur as a result of tasks performed by the Action). Each transition is labeled; the label consists of three parts, all optional: Event [Guard] / Action. The event is what triggers the transition; a transition cannot occur until its controlling event does. The guard is a Boolean expression that describes a condition -- the transition does not occur unless the condition is true (there can, in fact, be several transitions on the same event, with different guard conditions, as long as the guard conditions are mutually exclusive). Finally, the activity is a short, uninterruptible task. Two “special” events exist. These are entry and exit. If they are defined, and association with Activities, those Activities occur immediately on entry (before any actions) and immediately on exit, respectively. This is true for all transitions into and out of the state. Exit occurs before any activity associated with the transition, and entry (on the new state) occurs after. Entry activities occur before state actions. State

23 How does ProVision use the UML?
UML Diagram Usage How does ProVision use the UML?

24 Conclusion UML is a robust notation that can express information gathered throughout a project’s lifecycle. Adopting standard use of UML can improve communication between clients and developers. UML can be used as an effective data modeling tool as well as an object modeling tool.


Download ppt "Introduction to UML Todd Bacastow Penn State University Geography 583 Geospatial System Analysis & Design."

Similar presentations


Ads by Google