ΕΘΝΙΚΟ ΜΕΤΣΟΒΙΟ ΠΟΛΥΤΕΧΝΕΙΟ Σχολή Ηλεκτρολόγων Μηχανικών και Μηχανικών Υπολογιστών Τεχνολογία Λογισμικού, 7ο/9ο εξάμηνο 2018-2019 Τεχνολογία Λογισμικού Ν.Παπασπύρου, Αν.Καθ. ΣΗΜΜΥ, ickie@softlab.tua,gr Β.Βεσκούκης, Αν.Καθ. ΣΑΤΜ, v.vescoukis@cs.tua,gr Κ.Σαΐδης, ΠΔ 407, saiko@softlab.tua.gr
Εισαγωγή στη UML (1/2)
Uified Modelig Laguage OMG Stadard, Object Maagemet Group Based o work from Booch, Rumbaugh, Jacobso UML is a modelig laguage to express ad desig documets, software, systems ad more Created with OO aalysis ad desig, but has evolved to cover more tha software systems UML is NOT a methodology, process, etc Idepedet of implemetatio laguage
Uified Modelig Laguage Ope Stadard, Graphical otatio for Software Systems, from iitial coceptio to detailed desig, across the etire software lifecycle specificatio visualizatio costructio documetatio Support uderstadig of software to customers ad developers Support for diverse applicatio areas Based upo experiece ad eeds of the user commuity
History
UML cocepts Systems, Models, Views A model is a abstractio describig a subset of a system A view depicts selected aspects of a model A otatio is a set of graphical or textual rules for depictig views Views ad models of a sigle system may overlap each other Example System: Aircraft Models: Flight simulator, scale model Views: All blueprits, electrical wirig, fuel system
UML models, views, diagrams UML defies may diagrams, each of which is a view ito a model Diagram preseted from the aspect of a particular stakeholder Provides a partial represetatio of the system Is sematically cosistet with other views
UML diagrams Static views Dyamic views
UML diagrams Visual Paradigm CE Visual Paradigm olie
UML views: focus o what s eeded Not all systems require all views Sigle executio ode: drop deploymet view Sigle process: drop process view Very small program: drop implemetatio view A system might eed additioal views Data view, security view, Idetificatio of useful views depeds o the cotext ad iteded use of the UML model of a system Commuicatio with the cliet System specificatio System desig
A key cocept: stereotypes Stereotype: A mechaism for extedig the vocabulary (ad thus, the expressive power) of UML Why exted the vocabulary? Ecosystem- / stack- / framework- specific termiology Comprehesive architecture visualizatio Use with measure! actor boudary etity cotrol
Basic UML modelig Use Cases Capture requiremets Domai Model Capture process, key classes Desig Model Capture details ad behaviors of use cases ad domai objects Add classes that do the work ad defie the architecture
Basic UML modelig Use Case Diagrams Class Diagrams / Package Diagrams Iteractio Diagrams Sequece Diagrams Collaboratio (a.k.a. Commuicatio Diagrams) Activity Diagrams / State Trasitio Diagrams Compoet Diagrams / Deploymet Diagrams
Use Case diagrams What is a Use Case key cocepts Use cases represet a sequece of iteractio(s) for a type of fuctioality Actors represet roles. A role is a type of user of the system, ad ca eve be aother system (exteral system) Used durig requiremets elicitatio to represet exteral behavior The use case model is the set of all use cases. It is a complete descriptio of the fuctioality of the system ad its eviromet
Use cases vs. Requiremets A Use Case usually groups some requiremets together i the cotext of a iteractio of the system with some exteral etity. The graularity of the requiremets defiitio determies the level of groupig requiremets i use cases
Use Cases ad Actors A actor models a exteral etity which commuicates with the system ad triggers some of its fuctioality: User Exteral system Physical eviromet A actor has a uique ame ad a optioal descriptio Examples: Passeger: A perso issuig a ticket GPS device: Provides the system with GPS coordiates
Use Cases ad Actors A use case represets a class of fuctioality provided by the system as a evet flow A use case cosists of: Uique ame Participatig actors Etry coditios Flow of evets Exit coditios Special requiremets
Use Case: example Uique ame Υποβολή δεδομένων xls(x) Participatig actors Διαχειριστής dashboard Etry coditios xls(x) file is available; server has eough disk space free Flow of evets User drags file to desigated area; file is uploaded to the server Exit coditios File is saved o the server
Use Case diagrams: <<iclude>> ad <<exted>> Iclude: Behavior that has bee factored out of the Use Case, so that it ca be reused Arrow poits to the usig Use Case Exteds Exceptioal, rarely ivoked Use Cases Arrow poits to the exteded Use Case
Use Case Diagrams are useful for Determiig requiremets New use cases ofte geerate ew requiremets as the system is aalyzed ad the desig takes shape. Commuicatig with cliets Their otatioal simplicity makes use case diagrams a good way for developers to commuicate with cliets. Geeratig test cases The collectio of scearios for a use case may suggest a suite of test cases for those scearios. Use case descriptios provide the ifo eeded: ot use case diagrams! All use cases eed to be described for the model to be useful.
Use Case Diagrams A complete Use Case model (diagram)
Class Diagrams A Class Diagram Gives a overview of a system by showig its classes ad the relatioships amog them. class diagrams are static they display what iteracts but ot what happes whe iteractios occur Also shows attributes ad operatios of each class Good way to describe the overall architecture of system compoets
Class Diagram: Perspectives We draw Class Diagrams uder three perspectives m m m m Coceptual Software idepedet Laguage idepedet Specificatio Focus o the iterfaces of the software Implemetatio Focus o the implemetatio of the software
Classes: Not Just for Code A class represet a cocept A class ecapsulates state (attributes) ad behavior (operatios). Each attribute has a type. Each operatio has a sigature. The class ame is the oly madatory iformatio.
Istaces A istace represets a pheomeo (= a specific object). The ame of a istace is uderlied ad ca cotai the class of the istace. The attributes are represeted with their values. Class diagram Object diagram
UML Class Notatio A class is a rectagle divided ito three parts Class ame Class attributes (i.e. fields, variables) Class operatios (i.e. methods) Modifiers Private: - Public: + Protected: # Static: Uderlied (i.e. shared amog all members of the class) Abstract class: ame i italics
UML Class Notatio: Relatioships Associatio A relatioship betwee istaces of two classes, where oe class must kow about the other to do its work, e.g. cliet commuicates to server Idicated by a straight lie or arrow Aggregatio A associatio where oe class belogs to a collectio Idicated by a empty diamod o the side of the collectio Members ca exist idepedetly of the aggregate ("paret") e.g.: studets exist eve if there is o class scheduled
Associatio Details Ca assig ames to the eds of the associatio to give further iformatio Team -members: Employee -group -idividual 1 * Employee -Name : strig +ID : log #Salary: double -adfaf :bool +getname() : strig +setname() -calciteralstuf(fi x : byte, i y :decima)l
UML Class Notatio Compositio Strog form of Aggregatio Lifetime cotrol: compoets caot exist without the aggregate (e.g.: parts of a aircraft) Idicated by a solid diamod o the side of the collectio Iheritace Iheritace represets a "is-a" relatioship Key elemet of object orietatio Idicated by a hollow arrowhead poitig to the superclass ("paret")
UML Class diagram otatio
UML Multiplicities Liks o associatios to specify more details about the relatioship Multiplicities Meaig 0..1 zero or oe istace... m idicates to m istaces. 0..* or * zero to ulimited istaces 1 exactly oe istace 1..* at least oe istace
UML Class Diagram example
UML Class Diagram Example
Class diagram: Software architecture Architecture Descriptio 101 19 Remember: The map is ot the territory
Class diagram: OCG Simple Features Std