12
Class diagrams Terézia Mézešová

Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Embed Size (px)

Citation preview

Page 1: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Class diagrams

Terézia Mézešová

Page 2: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Class diagram

• static diagram, part of UML describing classes structure of system

• shows classes, their attributes and methods and relationships between classes

• classes represent main interactions in system and classes to be programmed

Page 3: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Classes

• name• attributes• methods

• abstract classes have name in italics

Page 4: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Attribute and method syntax

• visibility name : data_type• visibility name ( parameter_name : parameter_type, ... )

• visibility:• + public• - private• # protected• / derived• _ static

Page 5: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Relationships

class level:1. generalization2. realization

instance level:3. association4. aggregation5. composition

Page 6: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Generalization

• "is a" relationship, inheritance• instance of subtype is also instance of superclass

Page 7: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Realization

• one element realizes the behavior of second element• e.g. relationship between classes and interfaces showing that the

class realizes methods offered by the interface

Page 8: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Association

• represents static relationship between objects of two classes

Page 9: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Aggregation

• "has a" relationship• type of association relationship• can only involve two classes

Page 10: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Composition

• "owns a" relationship• stronger than aggregation• if the container class is destroyed, all contained classes must be

destroyed as well

Page 11: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Other types of relationships

• dependency - one class uses another at some point

• multiplicity:1. 0..1 - no or one instance2. 1 - exactly one instance3. 0..* - zero or more instances4. 1..* - at least one or more instances

Page 12: Class diagrams Terézia Mézešová. Class diagram static diagram, part of UML describing classes structure of system shows classes, their attributes and

Thank you for your attention