Presentation is loading. Please wait.

Presentation is loading. Please wait.

CompSci 280 S Introduction to Software Development

Similar presentations


Presentation on theme: "CompSci 280 S Introduction to Software Development"— Presentation transcript:

1 CompSci 280 S2 2107 Introduction to Software Development
UML

2 Today’s Agenda Topics: Reading: Introduction Activity Diagram
Object interaction diagrams Sequence Diagram Reading: Booch G.,The Unified Modeling Language User Guide, ch 19. Lecture09

3 UML Unified Modeling Language (UML)
When creating complex OO systems, where do we start? When building complex systems, it might be worthwhile to plan things out before you start coding! When building a house, we usually have a set of plans. The UML is a standard notation for writing software blueprints UML is a language which allows us to graphically model an OO system in a standardised format. This helps us (and others!) understand the system. There are many different UML diagrams, allowing us to model designs from many different viewpoints. Roughly, there are Structure diagrams (documenting the architecture), e.g. class diagrams Behaviour diagrams (documenting the functionality), e.g. use-case diagrams Lecture09

4 1.Introduction UML Diagrams
State Diagrams diagrams The UML is used to construct a model of a software system A model is a simplification of reality A model is thus an abstraction that exposes interesting properties while suppressing unnecessary detail A UML model comprises different diagrams, each focusing on a particular aspect of a system State Diagrams Class diagrams State Diagrams Use case diagrams State Diagrams Activity diagrams Model Component Diagrams Deployment diagrams State Diagrams Interaction diagrams Lecture09

5 1.Introduction UML diagram types
Activity diagrams, which show the activities involved in a process or in data processing . Use case diagrams, which show the interactions between a system and its environment. Sequence diagrams, which show interactions between actors and the system and between system components. Class diagrams, which show the object classes in the system and the associations between these classes. State diagrams, which show how the system reacts to internal and external events. perspective Lecture09

6 6 Lecture09 Borrower Reserve book Borrow copy of book
Return copy of book Update catalogue Librarian A Use Case diagram is user-centered and identifies system users (actors) and tasks. A Class diagram shows the static structure of a system in terms of classes, interfaces and their relationships. : LibraryMember theCopy : Copy borrow( theCopy ) : Book okToBorrow borrow borrowed An Interaction (sequence) diagram is concerned with dynamic behaviour and shows how objects exchange messages to fulfil a task. Not borrowable Borrowable returned( ) borrowed( ) [not last copy] borrowed( ) [last copy] A State diagram shows the states and transitions for an instance of particular class (Book in this case). : PC : Server servlet browser dbms <<http>> Internet LAN A Deployment diagram shows the deployment of software to hardware entities. 6 Lecture09

7 1.Introduction Tool Support: ArgoUML?
You will draw some class diagrams and use-case diagrams. Options: ArgoUML Supports forward- and reverse-engineering. Class diagrams  Java skeletons. Java classes  class diagrams. Not on lab image – you’ll have to download and unzip the binary distribution in your echome directory (or on your USB pendrive) then double-click on argouml.jar (this is an “executable jarfile”). Any general-purpose drawing package (e.g. Visio) By hand: This is your only option during exams and tests You’ll have to scan your drawings into your assignments (which are submitted online) Lecture09

8 2.Activity Diagram Activity diagrams describe the workflow behavior of a system.  The diagrams describe the state of activities by showing the sequence of activities performed.  they can show activities that are conditional or parallel. Activity diagrams do not give detail about how objects behave or how objects collaborate. An activity is an ongoing, though interruptible, execution of a step in a workflow (such as an operation or transaction) Represented with a rounded rectangle. Text in the activity box should represent an activity (verb phrase in present tense). Lecture09

9 2. Activity Diagram How to Draw an Activity Diagram
Diagrams are read from top to bottom and have branches and forks to describe conditions and parallel activities.  A fork is used when multiple activities are occurring at the same time.  A branch describes what activities will take place based on a set of conditions.  All branches at some point are followed by a merge to indicate the end of the conditional behavior started by that branch.  After the merge all of the parallel activities must be combined by a join before transitioning into the final activity state.    Lecture09

10 2.Activity Diagram Activity Diagram Example
Fork Branch Start State Merge Join Activity End State Lecture09

11 3.Object Interaction Diagrams
Object interaction diagrams show how class instances behave in terms of sending messages to one another This interactive behavior is represented in UML by two diagrams known as Sequence diagram and Collaboration diagram. The basic purpose of both the diagrams are similar. In UML, a sequence diagram is a popular form of interaction diagram where messages are time-ordered Interaction diagrams give a dynamic view of objects and show how they interact at run-time to fulfil a task Often used to model the way a use case is realized through a sequence of messages between objects. The purpose of Interaction diagrams is to: Model interactions between objects Assist in understanding how a system (a use case) actually works Verify that a use case description can be supported by the existing classes Identify responsibilities/operations and assign them to classes Lecture09

12 3.Object Interaction Diagrams Interaction diagram notation
Key elements of interaction diagrams are objects and messages (method calls) Active Objects “Life line” appears below active objects to indicate their lifespan Messages Arrowed lines that indicated communication between objects Notations: An instance, named “object”, of an unspecified class An instance, named “object”, of a class named “Class” An unnamed instance of class “Class” Message m Message reply r (optional) Object lifeline Focus of control (optional) object object : Class : Class m r Lecture09

13 4.Sequence Diagram Objects & Messages
an Order Line Objects: An object in a sequence diagram is rendered as a box with a dashed line descending from it. The line is called the object lifeline, and it represents the existence of an object over a period of time. Messages Messages are rendered as horizontal arrows being passed from object to object as time advances down the object lifelines. Conditions ( such as [check = “true”] ) indicate when a message gets passed Return: This arrow indicates a return from a previous message, not a new message. an Order Line a Stock Item [check = “true”] remove() check() Lecture09

14 4.Sequence Diagram Example:
Time Increasing --> All lines should be horizontal to indicate instantaneous actions. Additionally if ActivityA happens before ActivityB, ActivityA must be above activity A Lecture09

15 4.Sequence Diagram Iterations
an Order a Order Line Iteration: An iteration marker, such as * (as shown), or *[i = 1..n] , indicates that a message will be repeated as indicated. * prepare() Iteration marker Lecture09

16 Condition Object Message Iteration Self-Delegation Return Creation
an Order Entry window an Order an Order Line a Stock Item A Reorder Item A Delivery Item new [check = “true”] new [needsToReorder = “true”] needsToReorder() [check = “true”] remove() check() * prepare() prepare() Object Message Iteration Return Creation Condition Self-Delegation [Fowler,97] Lecture09

17 5. Examples: Part of a Vending Machine
Lecture09

18 Banking task: applying interest to a savings account
Points to note: Sequence diagrams are time- ordered Actual arguments can include literals or references to participating objects driver : Customer : SavingsAccount balance : Money accounts( ) applyInterest( ) multiply( 0.08 ) create( ) interest : Money interest add( interest ) create( ) newBalance : Money newBalance create( Transaction.INTEREST, interest, this ) : Transaction Lecture09

19 Sequence Diagram Exercise: ATM Machine
Draw a sequence diagram on cash withdrawal from ATM Lecture09


Download ppt "CompSci 280 S Introduction to Software Development"

Similar presentations


Ads by Google