UML Basics

1,074 views

Published on

All these contents are provided by Serdar Temiz, please give attribute.

Published in: Engineering, Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,074
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
12
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

UML Basics

  1. 1. UML Sectionsof thispresentation wereadapted from Martin Fowler UML Distilled: A Brief Guideto theStandard Object Modeling Language, 3rd Edition
  2. 2. History Design notation of variouskindsused since programming began: • Flow charts, Pseudo code, StructureDiagrams… With advent of OO, many conflicting notations (1980s, 1990s) Thesenotationswerecombined and unified (late 1990’s) UML extensively taught in universities (2000 - now).
  3. 3. UML: Unified Modeling Language An industry-standard graphical languagefor specifying, visualizing, constructing, and documenting theartifactsof softwaresystems, aswell asfor businessmodeling. TheUML usesmostly graphical notationsto expressthe OO analysisand design of softwareprojects.  Simplifiesthecomplex processof softwaredesign UML can beused to describe:  theorganization of aprogram  how aprogram executes  how aprogram isused  how aprogram isdeployed over anetwork  …and more What is UML?
  4. 4. Why UMLforModeling? A diagram/picture= thousandswords Usesgraphical notation to communicatemoreclearly than natural language(imprecise) and code(too detailed). Makesit easier for programmersand softwarearchitectsto communicate. Helpsacquirean overall view of asystem. UML isno t dependent on any onelanguageor technology. UML movesusfrom fragmentation to standardization.
  5. 5. 3 Waysto UseUML (Both forward & reverseengineering) 1) Sketch e.g. at white board 1) Most common, quick and informal 2) Communication & understanding 2) Blueprint 1) Detailed design, implemented by programmer 2) May havetoolssupporting diagramming 3) Programming Language 1) Toolstranslatediagramsto executablecode
  6. 6. During Software Lifecycle: UMLCan Be Used at Various Stages Analysis: OOA • What issystem to do? What servicesisit to provide? Provide requirementsfor designer. Design: OOD • What will betheparts& structureof thesystem? How will they interact? Provideblueprint for programmer. Programming: OOP
  7. 7. Classification of UMLDiagrams Structure 1) Class diagram 2) Component diagram (cmptscan beindependently purchased and replaced) 3) Component structurediagram 4) Deployment diagram (what goeson what machine& place) 5) Object diagram 6) Packagediagram (pkg = group of classes, e.g. namespace) There are 13 + Kinds of UMLDiagrams
  8. 8. Classification of UMLDiagrams (cont.) Behavior 7) Activity diagram (flow chart) 8) Use Case diagram (scenarios foruse of system) 9) StateMachinediagram 10) Sequence diagram 11) Communication diagram (dataflow diagrams) 12) Interaction diagram (activity + sequencediagrams) 13) Timing diagram
  9. 9. Class Diagrams
  10. 10. Class diagrams A classdiagram isoften all that isneeded to describea particular Design Pattern A classdiagram showsclasses, interfaces, and their relationships We’ll cover most of classesand interfaces, and afew of the most important relationships Thepurposeof theclassdiagram isto show thetypesbeing modeled within thesystem. 10
  11. 11. "classifiers." UML modelstypesmay include: aclass an interface adatatype acomponent.
  12. 12. Class Class Name Attribute : type Operation (arg list) : return type Abstract operation Various parts are optional
  13. 13. Example UMLClass Diagram 13 http://www.ibm.com/ -http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/bell_fig5.jpg
  14. 14. Instance Specification (Object) ObjectName: Class Name Attribute : type Operation (arg list) : return type Abstract operation Various parts are optional
  15. 15. An example of Class Account_Name - Custom_Name - Balance +AddFunds( ) +WithDraw( ) +PayInvoice( ) Name Attributes Operations
  16. 16. Class Example class Checking { private: char Customer_name[20]; float Balance; public: AddFunds(float); WithDraw(float); PayInvoice(float); set_name(string); get_name(); set_balance(float); get_balance(); };
  17. 17. Relationships between Class Diagrams Association-- arelationship between instancesof thetwo classes. There isan association between two classesif an instanceof oneclassmust know about theother in order to perform itswork. In adiagram, an association is alink connecting two classes. Aggregation-- an association in which oneclassbelongsto acollection. An aggregation hasadiamond end pointing to thepart containing the whole. Generalization-- an inheritancelink indicating oneclassisasuperclass of theother. A generalization hasatrianglepointing to thesuperclass. 17
  18. 18. Notation of Class Diagram: association Bi-directional association Associationsareassumed to bebi-directional e.g. Flight and plane notation: Uni-directional association e.g. Order and item notation: Associations represent relationships between instances of classes .
  19. 19. Association: Multiplicity and Roles University Person 1 1 * * Multiplicity Symbol Meaning 1 One and only one 0..1 Zero or one M..N From M to N (natural language) * From zero to any positive integer 0..* From zero to any positive integer 1..* From one to any positive integer 0…8.. From zero to eight 8..14 From eight to fourteen teacheremployer RoleRole “A given university groups many people; some act as students, others as teachers. A given student belongs to a single university; A given staff belongs to a single university; a given teacher may or may not be working for the university at a particular time.” student staff * 0..1
  20. 20. Notation of Class Diagram: Aggregation AGGREGATION Aggregation: expresses a relationship among instances of related classes. Containee Classes Flat Rooms Storage Room Example 1 Containee Classes Car Motor Wheels Example2 AGGREGATION 41
  21. 21. Generalization (Inheritance) Supertype Subtype 1 Subtype 2 Generalization expresses a relationship among related classes. It is a class that includes its subclasses.
  22. 22. Generalization Example http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/bell_fig10.gif
  23. 23. Elements of Sequence Diagrams Name: Class New object Create Message Return Delete Self-call Lifelines The dotted line that extends down the vertical axis from the base of each object. Messages Labeled as arrows, with the arrowhead indicating the direction of the call. Activation bar The long, thin boxes on the lifelines are method-invocation boxes indicting that indicate processing is being performed by the target object/class to fulfill a message. Rectangle also denotes when object is deactivated. Deletion (X) Object’s life ends at that point Activation bar Sequence Diagrams
  24. 24. Example forSequence Diagram [Fowler] Wehavean order and aregoing to invokeacommand on it to calculateitsprice. To do that, theorder needsto look at all theline itemson theorder and determinetheir prices, which arebased on thepricing rulesof theorder line’sproducts. Having donethat for all thelineitems, theorder then needsto computean overall discount, which isbased on rulestied to thecustomer.
  25. 25. Example forSequence Diagram [Fowler] Wehavean order and aregoing to invokeacommand on it to calculateitsprice. To do that, theorder needsto look at all thelineitemson theorder and determinetheir prices, which arebased on thepricing rulesof theorder line’s products. Having donethat for all thelineitems, theorder then needsto computean overall discount, which isbased on rulestied to thecustomer.
  26. 26. Example Sequence Diagram anOrder anOrderLine aProduct aCustomer calculatePrice getQuantity getProduct getPricingDetails getBasePrice calculateDiscounts getDiscountInfo aProductFound message Participant Lifeline Return Activation Self call Message Operations Object: Class Message
  27. 27. USECASES DIAGRAM Use cases. A usecasedescribesasequenceof actionsthat provide something of measurablevalueto an actor and isdrawn asa horizontal ellipse. Actors. An actor isaperson, organization, or external system that playsarolein oneor moreinteractionswith your system. Actorsare drawn asstick figures
  28. 28. Website Administration Who managesthewebsite? What typeof different rolesof admin and help desk have
  29. 29. Website Administration g www.uml-diagrams.or
  30. 30. Business Use Case Diagram forAirport Check- In and Security Screening Business actors :? Business use cases ? PLEASE DISCUSS AND EXPLAIN WHY?
  31. 31. Business Use Case Diagram forAirport Check- In and Security Screening Business actors :Passenger, Tour Guide, Minor (Child), Passenger with Special Needs (all playing external rolesin relation to airport business.) Business use cases are  Individual Check-In,  Group Check-In (for groupsof tourists),  Security Screening Baggage Check-in and Baggage Handling extend Check-In usecases, WHY?
  32. 32. Business Use Case Diagram forAirport Check- In and Security Screening
  33. 33. Activity Diagram Activity diagram isused to show message flow from oneactivity to another. Activity Diagrams: Draw theactivity flow of asystem. Describethesequencefrom oneactivity to another. Describetheparallel, branched and concurrent flow of thesystem.
  34. 34. http://www.sparxsystems.com/resources/uml2_tutorial/uml2_activitydiagram.html An initial or start node Activity final node Object Decision Node Fork/Branch and Join Nodes Merger Node

×