UML Basic Structural Modeling Part II UML Basic
UML Basic Structural Modeling Part II UML Basic Structural Modeling 1
Basic Structural Modeling • Classes m Attributes, Operations, Responsibilities • Relationships Dependency, Generalization, Association, Role, Multiplicity, Aggregation m • Common Mechanisms Specifications, Adornments, Common Divisions, Extensibility Mechanisms m • Diagrams m Class , Object , Component , Deployment Dagrams UML Basic Structural Modeling 2
Common Mechanisms m Specifications m Adornments m m m Notes Common Divisions Extensibility Mechanisms m m m stereotypes tagged values constraints UML Basic Structural Modeling 3
Adornments: Note • Adornment that stands alone • Note is a graphical symbol for rendering constraints or comments attached to an element • Used to specify things like requirements, oservations, reviews, and explanations • Can be simple text, an embedded URL, a link to a document Note UML Basic Structural Modeling 4
Adornments: Note • Examples Mission full_name : string See URL Shuttle. nasa. gov Shuttle start_engines() stop_engines() fuel_level() : integer launch(t: time) Launch time is computed from ephemeris UML Basic Structural Modeling 5
Stereotypes • Allows to extend the vocabulary of the UML • Allows to create new building blocks, specific to your problem • Can be applied to any element (Class, Attribute, Operation, …) • Can be represented by m << stereotype >> m new icon m both UML Basic Structural Modeling 6
Stereotypes m m m a class can have a stereotype indicating what basic type of class it is (e. g. controller, actor, interface) represent a metaclassification of the class appear within guillemets in normal type above the class name «user interface» Window size : Area = (100, 100) visibility : Boolean = invisible display () hide () UML Basic Structural Modeling 7
Operation Stereotypes m m stereostypes can also be used to group together operations with common characteristics represent a metaclassification of the operation «exception» Bad. Socket throw() log (String) «helper» set. Socket(Socket) «access» get. ID(): Socket. ID set. ID(Socket. ID) UML Basic Structural Modeling 8
Stereotypes Examples << NASA Object >> Shuttle weight : Integer age : Integer status: enum = on-ground Spacecraft UML Basic Structural Modeling 9
Tagged Values • • Apply to any element of the UML Metadata that applies to the element not its instances Represent arbitrary information expressed in text form Commonly used to store Project Management information • Examples: m author of an element Author=John Smith m testing status Test = No m version number Version # = 4. 2 UML Basic Structural Modeling 10
Constraints m m restrict the values that object or links can assume expressed as arbitrary expressions enclosed in braces near the constrained elements often use navigation expressions constraints between two elements are depicted using a dotted, labeled line 4. . 6 Member-of Astronaut 1 {subset} Commander-of * * UML Basic Structural Modeling Crew 11
Constraint Examples boss * worker Person employee employer * Company {person. employer = person. boss. employer} UML Basic Structural Modeling 12
Hint and Tips • Do not abuse Notes, Stereotypes and Tagged Values • Should be used for enhancing communication • Make sure that there is no other way to express what you want • Use Notes as links to documents when too long UML Basic Structural Modeling 13
Diagrams • Class Diagram m Classes, Interfaces, Collaborations • Object Diagram m Objects • Component Diagram m Components • Deployment Diagram m Nodes UML Basic Structural Modeling 14
Diagrams • Used to organize the elements of interest • Nine diagrams in UML • Present 5 different Views: m Use Case, Design, Process, Implementation and Deployment Views UML Basic Structural Modeling 15
Class Diagram • General properties m Name m Graphical content which is a projection into the model • Specific Properties Contains Classes, Interfaces, Collaborations, Relationships m • Sometimes put package, subsystem and instances UML Basic Structural Modeling 16
Class Diagram m shows a set of Classes, Interfaces and Collaborations m captures the static structure of the system m foundation for the other models m m describes the properties and relationships of the objects in the system all icon/diagram components are optional (you can show as much or as little information as appropriate) m model vocabulary of system m model simple collaborations m model logical database schema UML Basic Structural Modeling 17
Class Diagram Example Company Department Office Headquarters Person UML Basic Structural Modeling 18
Hints and Tips • Multiple Class Diagrams are usually needed • Each focus on different aspects of the system • Provides detail consistent with its level of abstraction • Layout is important to convey the information m things semantically close should be physically close m no crossing lines for relationships • When Diagram becomes complex, break it into multiple diagrams UML Basic Structural Modeling 19
Class Diagram Modeling Exercice • Develop a Class Diagram describing a school UML Basic Structural Modeling 20
- Slides: 20