Download presentation
1
What is UML? A modeling language standardized by the OMG (Object Management Group), and widely used in OO analysis and design A modeling language is a visual language for representing software blueprints Latest version is 2.0 UML provides a standard notation, semantics for a set of OO abstractions CS 3500
2
UML Overview UML defines a visual representation of a concept
Everything that is defined in this has meaning Just like when writing code, you use () or , or + to represent something Same is true in UML So, be careful of the types of arrows, boxes, etc. that you use Be careful of where you put other symbols Remember that there is a REAL syntax defined for UML You can’t just write/draw whatever you like Our focus – reading UML Class diagrams Next semester, writing them and other diagrams CS 3500
3
UML Class Class name Data members (attributes) Instance methods
These compartments are optional. But if you need methods, then you have to have at least empty data member compartment. Instance methods Class method (static) Return types Arguments Important – if something isn’t specified, then that doesn’t necessarily mean that it isn’t there. For example, does name take an argument or not, does it return a value? CS 3500
4
visibility name : type multiplicity = default {property-string}
Class Attributes Attributes are the instance and class data members Class data members (underlined) are shared between all instances (objects) of a given class (think static). Data types shown after ":" Visibility shown as + public - private # protected Attribute compartment Attribute Model visibility name : type multiplicity = default {property-string} CS 3500
5
visibility name (parameter-list) : return-type {property-string}
Class Operations Operations are the class methods with their argument and return types Public (+) operations define the class interface Class methods (underlined) have only access to class data members, no need for a class instance (object) Parameter List – direction name: type = default Direction Model – direction – in, out, inout Operations compartment Operations Model visibility name (parameter-list) : return-type {property-string} CS 3500
6
Multiplicity - 1 Indicates how many objects may fill the property
1 – exactly one – may or may not have one * – zero or more n .. m – from n to m where n < m Default is [1] But it is best to not use default even if value is 1 to make it clear Question – if you indicate that something is a n..m multiplicity, then how is this realized? CS 3500
7
Unary Association A knows about B, but B knows nothing about A
UML Comment These two diagrams are identical in what they mean. Arrow shows direction of association in direction of dependency CS 3500
8
Unary Association IS an Attribute
Exactly the same as an attribute Did you hear me? Exactly the same!!! Solid line (source to target) Name goes at the target end, plus multiplicity It is WRONG to include both an association and a attribute of the same thing That implies that BOTH exist at the same time What is the difference between a unary association (line) and an attribute? IT IS THE SAME THING!!!!! Don’t forget!!!! CS 3500
9
Binary Association Binary association: both classes know each other
Usually "knows about" means a pointer or reference Other methods possible: method argument, tables, database, ... Implies dependency cycle CS 3500
10
Dependency Weak relationships (also transitory):
Class A simply knows of class B E.g., a method in A creates and immediately returns an object of class B That is: a change in one may force changes in the other although there is no explicit association between them. CS 3500
11
Generalization (Inheritance)
Base class or super class Arrow shows direction of dependency Derived class or subclass CS 3500
12
Aggregation Aggregation = Association with "whole-part" relationship
Shown by hollow diamond at the "whole" side No lifetime control implied CS 3500
13
Composition Composition = Aggregation with lifetime control
Shown by filled diamond at the "owner" side Lifetime control implied Lifetime control can be transferred Lifetime control: construction and destruction controlled by "owner" → call constructors and destructors (or have somebody else do it) CS 3500
14
Composition/Aggregation Notations
whole part composition aggregation part CS 3500
15
Describe This Diagram CS 3500
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.