1 / 0

Lecture # 04 The Unified Modeling Language

SWE 316: Software Design and Architecture. Lecture # 04 The Unified Modeling Language. Ch 3. Requirements Analysis. Review of the relationships between classes, UML models and notations. Design. Framework. Architecture. Detailed Design. Implementation.

andren
Download Presentation

Lecture # 04 The Unified Modeling Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SWE 316: Software Design and Architecture

    Lecture # 04The Unified Modeling Language

    Ch3 Requirements Analysis Review of the relationships between classes, UML models and notations. Design Framework Architecture Detailed Design Implementation Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.
  2. 2/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example The Unified Modeling Language (UML) UML is a graphical notation for expressing object-oriented design UML is managed by the Object Managed Group (OMG) UML design expressions are called models
  3. 3/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Classes at Detailed Design Canister Class name canister +numCanisters: int -numWafers: int -size: float Attribute: type +:Visible from without +display() -getNumOpenSlots() +setStatus() Operations Responsibilities: -- describes each canister undergoing fabrication wafer Place for comments
  4. 4/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Class Relationships in UML Class relationships Inheritance and interface Aggregation Composition Dependency Association UML uses the term package for collecting design elements such as classes.
  5. 5/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Representing a Class in UMLUML represents a class with a rectangle containing the class name. We display additional information within the rectangle as needed: Variables, methods, etc.
  6. 6/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example UML Notation and Typical Implementation package of classes MyPackage package MyPackage; abstract class MyAbstractClass { … } abstract class MyAbstractClass package MyPackage; class MyDerivedClass extends MyAbstractClass { intatt; . . . . . void myFunction(ReferencedClass r) { . .. } } inheritance MyDerivedClass att: int myFunction()
  7. 7/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Interfaces UML Notation/Java Implementation interface MyAbstractClass . . . . class MyClass implements MyInterface { . . . . . } interface MyInterface myMethod() realization MyClass myMethod()
  8. 8/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Representing Inheritance in UML Representing Inheritance in UML UML represents inheritance and interface realization with an open triangle. Inheritance: with solid line Realization: with dotted line
  9. 9/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Class Relationships in UML: Aggregation Class A aggregates class B if A objects require B objects in a structural sense It includes the structural inclusion of objects of one class by another It models “whole – part” relationship It is denoted with a diamond Composition is a stronger form of aggregation in which the aggregated object exists only during the lifetime of the composing object
  10. 10/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Aggregation : UML Notation / Implementation MyClass att: int myFunction() aggregation MyAggregatedClass ac 1 class MyClass { MyAggregatedClass ac; intatt; . . . . . } Composed object exists only in the scope of owner object composition ac
  11. 11/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Representing Aggregation in UML Representing Aggregation in UML Class A aggregates class B if A objects require B objects in a structural sense – typically with an instance variable. UML symbol is an open diamond.
  12. 12/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Class Relationships in UML: Dependency Class A depends on class B if objects of A require objects of B for their definition. It is denoted by dotted line arrow Dependency includes inheritance and aggregation Dependency in UML indicates that a method of one class utilizes another class
  13. 13/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Dependence : UML Notation … and …Typical Implementation MyDependentClass att: int myFunction() MyReferencedClass class MyDependentClass { . . . . . void myFunction1( MyReferencedClass r ) { . .. } MyReferencedClass myFunction2( … ) { . .. } void myFunction3( … ) { MyReferencedClass m … } } dependence (reference to a class) parameter or return type or local variable type
  14. 14/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Representing Dependency Class A depends on class B if A objects require B objects for their definition. In practice, this means that B appears in at least one method of A. UML representation: a dotted arrow.
  15. 15/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Class Relationships in UML: Association Objects of one class depends on objects of the other class in structural sense. It is denoted with solid line between two classes
  16. 16/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Association : UML Notation /Implementation employs 1..n 1..3 Employer Employee is employed by class Employer { Employee[ ] employees; . . . . . } class Employee { Employer[ ] employers; . . . . . } What is wrong with this design?
  17. 17/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Customer Mail Application CustomerMailApplication generateMail() getCustomerTypeFromUser() main() Customer createMail() customer 1 DelinquentCustomer createMail() MountainCustomer createMail() RegularCustomer createMail()
  18. 18/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Use Cases A use case is a sequence of actions taken by an application and its user A use case has three components Name Actor: the type of user of the application Interaction between the actor and application Use cases are particularly useful for requirements analysis
  19. 19/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Use Cases For Video Store Application Activate Actor hits any key. Application displays main menu. Check in 1. . . . . Precondition: Application has been activated Actor clicks “check out.” Actor swipes bar code. Applicationprompts for rental duration. Actor enters duration. Application stores record. Application prints customer’s account status. clerk Check out Add video stocker . . . . . . . . . 1. …
  20. 20/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Use Cases (cont...) Combining use cases Use cases can be dependent on other use cases extends relationship: like inheritance relationship uses relationship: like aggregation relationship
  21. 21/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Use Case Generalization & Usage A.Application displays main options B.User selects icon Perform warehouse transaction Warehouse worker «uses» ControlApplication «extends» Modify Stock (i).Application displays logo (ii). “Perform warehouse Transaction” use case. (iii) Application displays farewell screen (iv) Application shuts down A.Application displays main options 1.User moves cursor to stock icon B.User selects icon 2. Application displays stock window Dispatcher
  22. 22/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Sequence Diagrams Sequence diagrams are graphical representations of control flow Sequence diagrams are useful for describing executions that involve several classes Sequence diagrams require us to think in terms of objects Sequence Diagrams A sequence diagram shows the order in which methods of various objects execute.
  23. 23/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Beginning of Sequence Diagram for Check Out Use Case Note 1 Clerk :MainScreen :BarCodeReader :CheckoutOptionDisplay doCheckout() Note 0 order :Checkout } read() Step 2 of use case Note 2 { initiate() Step 3 of use case show() Note 3
  24. 24/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Beginning of Sequence Diagram for Check Out Use Case User :MainScreen :BarCodeReader :CheckoutOptionDisplay doCheckout() :Account :Checkout 1. read() 2.1 initiate() 2.2 create() 2.3 show() 3. setDuration() Use case: 1. User swipes bar code 2. Application prompts for rental duration 3. User enters duration 4. Application stores record 5. Application prints customer’s account status 4. store() 5. print()
  25. 25/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Building a Sequence Diagram 1 1. Identify the use case whose sequence diagram you will build (if applicable). 2. Identify which entity initiates the use case the user, or an object of a class name the class name the object 3. Draw a rectangle to represent this object at left top use UML object:Class notation 4. Draw an elongated rectangle beneath this to represent the execution of an operation 5. Draw an arrow pointing right from its top myObject :MyClass
  26. 26/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Building a Sequence Diagram 2 6. Identify which entity handles the operation initiated an object of a class name the class name the object 7. Label the arrow with the name of the operation 8. Show a process beginning, using an elongated rectangle 9…… Continue with each new statement of the use case. myObject :MyClass myObject1 :MyClass1 operation()
  27. 27/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example State Models The state of an application is its situation or status A state of an object is defined by the values of the object’s variables States and substates are denoted by rounded rectangles Event --- something whose occurrence is sensed directly by objects of the class in question. Transitions An event may cause an object to transition from its current state to another state Transition is denoted by a labeled arrow State transition diagram (also known as state charts)
  28. 28/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example State Diagrams Some applications or parts thereof are conveniently thought of as being in one of several possible states. UML state diagrams help us visualize these, and the events that cause transitions among them.
  29. 29/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example States for OnlineShopper Class Browsing ItemsChosen CheckingOut Incomplete CreditUnderValidation CreditDenied Complete
  30. 30/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Conditions on Events [credit card data incomplete] [credit card data complete] Hit Submit button Incomplete CreditUnderValidation
  31. 31/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example State/Transition Diagram for OnlineShopper Class select item put back last item [credit card data incomplete] ItemsChosen select item Browsing Hit checkout button CheckingOut hit Submit button Incomplete hit Quit [credit card data complete] hit OK CreditUnderValidation denial received hit OK validation received CreditDenied Complete
  32. 32/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Activity Chart Notation Do Something An updated and enhanced form of flowcharts Do Something More [condition true] else } In parallel Do A Task Do Another Task Do Even More
  33. 33/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Flowchart for soughtFact.proveBack() Fact Rule else Another rule R exists with soughtFact as its consequent else soughtFact in factList Apply R.proveAntecedents()* Report FALSE else proof succeeded * Prove that every antecedent fact is true Report TRUE
  34. 34/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Example: Specifications for Figure Drawing Facilitate drawing stick figures Drag to vicinity to auto-complete Feet can be rectangles or ellipses (Rest to be specified) Releasing dragged figure anywhere in this area causes it to appear in position at end of left leg
  35. 35/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Bad Attempt: “A Foot is Either an Ellipse or a Rectangle” Ellipse Rectangle Foot
  36. 36/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Better Attempt: “A Foot is Either an Ellipse or a Rectangle” Ellipse Foot Rectangle EllipseFoot RectangleFoot
  37. 37/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Another Attempt: “A Foot is Either an Ellipse or a Rectangle” Foot FootShape Ellipse Rectangle
  38. 38/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Best Attempt So Far: “A Foot is Either an Ellipse or a Rectangle” FootShape drawAsEllipse() drawAsRectangle() Foot draw() Ellipse draw() Rectangle draw()
  39. 39/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Class Model Showing All Dependencies Area releaseCursor() GeometricFigure Leg FootShape drawAsEllipse() drawAsRectangle() Foot draw() Ellipse draw() Rectangle draw() Position
  40. 40/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Sequence Diagram for Figure Drawing Application :Area :Foot :FootShape :Ellipse releaseCursor ( GeometricFigure aGeometricFigure ) draw ( Leg aLeg, aGeometricFigure ) drawAsEllipse* ( Position aPosition ) draw( aPosition ) * or drawAsRectangle() …
  41. 41/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Summary of UML Models Use Cases Actor / application interactions Sequence Diagrams Objects Sequence of methods calling methods among objects Class Models Activity Diagrams Flow of control State Diagrams States Transitions among states caused by events
  42. 42/42 Class Diagrams Use Cases Sequence Diagrams State Diagrams Activity Diagram Example Summary :Relationships Between Classes Dependency member method mentions another class Association structural e.g., sale / receipt Aggregation common kind of association e.g. airplane / wing one-way “has-a” Inheritance “is-a”
More Related