Www.ddss.arch.tue.nl 7M822 UML Class Diagrams advanced concepts 14 October 2010.

Slides:



Advertisements
Similar presentations
UML (cont.) “The Unified Modeling Language User Guide” by G. Booch, J. Rumbaugh and I. Jacobson ● Classes ● Relationships ● Class diagrams ● Examples.
Advertisements

Object-oriented modeling Class/Object Diagrams
7M822 UML Class Diagrams 7 October 2010.
Stereotypes Stereotypes provide the capability to create a new kind of modeling element. –They can be used to classify or mark modeling elements. –A type.
1 CIS224 Software Projects: Software Engineering and Research Methods Lecture 4 Class Models (Based on Fowler (2004, Chapters 3 & 5) and Stevens and Pooley.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 Class and Object Diagrams PRACTICAL OBJECT-ORIENTED DESIGN WITH.
UML – Class Diagrams.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
Slide 1 Systems Analysis & Design CS183 Spring Semester 2008 Dr. Jonathan Y. Clark Course Website:
Chapter 14 (Web): Object-Oriented Data Modeling
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.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Class Diagram & Object Diagram
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 Class and Object Diagrams PRACTICAL OBJECT-ORIENTED DESIGN WITH.
7M822 UML Class Diagrams advanced concepts 15 September 2008.
Modelling classes Drawing a Class Diagram. Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the.
Chapter 14: Object-Oriented Data Modeling
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
Object-Oriented Analysis and Design
- U nified M odeling L anguage Rajthilak S Alfonso G B.
UML Unified Modeling Language. What is UML? Unified Modeling Language (UML) is a standardized, general-purpose modeling language in the field of software.
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
OBJECT AND CLASES: THE BASIC CONCEPTS Pertemuan 8 Matakuliah: Konsep object-oriented Tahun: 2009.
CSCI-383 Object-Oriented Programming & Design Lecture 9.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Database Management System Prepared by Dr. Ahmed El-Ragal Reviewed & Presented By Mr. Mahmoud Rafeek Alfarra College Of Science & Technology Khan younis.
R McFadyen Chapter 7 Conceptual Data Modeling.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
Distributed Java Programming Distributed Java Programming Class #2 August 22, 2002.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
CHAPTER 13 (ONLINE): OBJECT-ORIENTED DATA MODELING © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
1 © Prentice Hall, 2002 Chapter 14: Object-Oriented Data Modeling Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 15: Object-Oriented Data Modeling Modern Database Management 9 h Edition Jeffrey A.
Databases : Data Modeling 2007, Fall Pusan National University Ki-Joune Li.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 13 (Online): Object-Oriented Data Modeling Modern Database Management 10 th Edition.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
Chapter 16 Applying UML and Patterns Craig Larman
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 03. Classes,
1 Class Diagrams: Advanced Concepts. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are the most commonly used diagrams.
Class diagram Used for describing structure and behaviour in the use cases Provide a conceptual model of the system in terms of entities and their relationships.
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Lecture 1: UML Class Diagram September 12, UML Class Diagrams2 What is a Class Diagram? A class diagram describes the types of objects in the system.
Class Diagram. Classes Software Design (UML) Class Name attributes operations A class is a description of a set of objects that share the same attributes,
Object-Oriented Data Modeling
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis: Associations. 2 Object Oriented Modeling BUAD/American University Class Relationships u Classes have relationships between each.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Object Oriented Analysis and Design Class and Object Diagrams.
 Week08.  Review Schedule Weeks 8-14  This week o Review last class o Introduce Class Diagrams o ICE-03 Sheridan SYST Engineering Quality Systems.
Class Diagram Chapter 21 Applying UML and Patterns Craig Larman.
1 Unified Modeling Language, Version 2.0 Chapter 2.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
- U nified M odeling L anguage. GO TO USER ROLES PAGE Many Stakeholders, many views  Architecture may be many things to many different stakeholders 
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A.
Object Modeling THETOPPERSWAY.COM. Object Modelling Technique(OMT)  Building a model of an application domain and then adding implementation.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Class Diagram Lecture # 1. Class diagram A Class Diagram is a diagram describing the structure of a system shows the system's classes Attributes operations.
Modeling with UML – Class Diagrams
UML Class Diagrams: Basic Concepts
Object Oriented Analysis and Design
Software Engineering Lecture #11.
UML Class Diagram.
Understand and Use Object Oriented Methods
Object Oriented System Design Class Diagrams
Presentation transcript:

7M822 UML Class Diagrams advanced concepts 14 October 2010

7M822 UML Class Diagrams The class diagram provides a static structure of all the classes that exist within the system. Classes are arranged in hierarchies sharing common structure and behaviour and are associated with other classes. Class diagrams are used in: Analysis To build a conceptual domain model with semantic associations between concepts Design Structural model of a design in terms of class interfaces Implementation Source code documentation, exposing the implementation 2

7M822 An object is a thing that can be tangible or intangible. Examples tangible : bike, car, house intangible : order, account Objects An object has properties. Example a Customer has a name and address Customer Name Address 3

7M822 Property of object = attribute + value (Multiple) Objects Adacs: Customer Name = Adacs Address = Enschede Primo: Customer Name = Primo Address = Grave Multiple objects  unique identity 1247: Customer Custno = 1247 Name = Adacs Address = Enschede 9378: Customer Custno = 9378 Name = Primo Address = Grave 4

7M822 Link = connection between objects Connection between Objects 1247: Customer Custno = 1247 Name = Adacs Address = Enschede 345T7: Order Orderno = 345T7 dateReceived = 10/10/05 Price = U2: Order Orderno = 902U2 dateReceived = 07/04/05 Price =

7M822 Class class is abstract concept each object is instance of a class classes classify objects attribute has no values Class Customer Custno Name Address Order Orderno dateReceived Price Object analysis  than values to attributes 6

7M822 Attribute has no values Association is relation between classes Class Diagram Customer Custno Name Address Order Orderno dateReceived Price Link is instance of association 1 * 7

7M822 Class diagram A class diagram describes the type of objects in a system and the static relationships between them. Static relations: – Associations – Subtypes Static structure: – Attributes – Operations 8

7M822 Class – operations An operation is the implementation of a service that can be requested from any object of the class in order to affect behaviour. Operations are used to manipulate the attributes or to perform other actions. Operations are normally called functions, but they are inside a class and can be applied only to objects of that class. An operation is described with a return-type, a name and zero or more parameters. Together, the return-type, name, and parameters are called the signature of the operation. The signature describes everything needed to use the operation. 9

7M822 10

7M822 Class - associations Associations are structural relationships where instances (objects) of one class are connected to instances (objects) of another class. –an employee works for a company –a company has a number of offices An association is normally bidirectional, which means that if an object is associated with another object, both objects are aware of each other (navigation is bidirectional by default). Binary association connects exactly two classes. N-ary connects many classes. The most common association is just a connection between classes. 11

7M822 Association adornments: name, role The association has a name - the descriptive term, often a verb, for the association. Each association has two association ends; each end is attached to one of the classes in the association. An end can be explicitly named with a label. This label is called a role name (association ends are often called roles). PersonCompany employee employer works for PersonCompany employee employer  has employment for 12

7M822 Associations: multiplicity Multiplicity defines the number of objects associated with an instance of the association. –Default of 1 (1: 1) –0 or 1: 0..1 –Zero or more (0..infinite): * –1 or more (1..infinite): 1..* –n..m; range from n to m inclusive CarPerson transports passenger CarPerson transports passenger 5 CarPerson transports passenger * CarPerson transports passenger 1..* CarPerson transports passenger

7M822 14

7M822 Generalization A specialization / generalization relationship, in which objects of the specialized element (child) are substitutable for objects of the generalized element (parent). –Superclass – the generalization of another class, the child. –Subclass – the specialization of another class, the parent. Customer Corporate Customer Personal Customer 15

7M822 Generalization - characteristics Identify common features concerning behaviour and knowledge. Define these common features on a higher level in the inheritance hierarchy. The aim is at behaviour more than knowledge when combining classes. Generalization is a bottom-up process. A superclass includes all common properties of its subclasses. 16

7M822 Specialization - characteristics Define a new class which is a special appearance of an existing class. Specialization is a top-down process. A subclass can have attributes and operations that are specific for that sub-class. A subclass may redefine operations of its super-class 17

7M822 18

7M822 Constraints The basic constructs of association, attribute, and generalization do much to specify important constraints. They cannot indicate every constraint. These constraints still need to be captured; the class diagram is a good place to do that. The UML allows you to use anything to describe constraints. The only rule is that you put them inside braces { }. 19

7M822 20

7M822 Attribute analysis It is not always clear which attributes belongs to which classes by finding out the class attributes. An attribute is assigned to that class where it is certainly a feature. For example: a project leader has the attributes name, department and age. But what to do with the attributes project number, project duration, starting time, and budget? These attributes clarifies something about the relation between project leader and type of project. This often happens if a n:m relation refers to an association between two classes. In that case, we can define a new class, for instance project management. 21

7M822 Aggregation and Composition Aggregation is a special form of association that specifies a whole-part relationship between the aggregate (the whole) and a component (the part). Composition is a form of aggregation with strong ownership and coincident lifetime of the parts by the whole; parts with nonfixed multiplicity may be created after the composite itself, but once created they live and die with it; such parts can also be explicitly removed before the death of the composite. 22

7M822 Aggregation and Composition: example 23

7M822 Object diagram An object diagram is a diagram that shows a set of objects and their relationships at a point in time; object diagrams address the static design view or static process view of a system. An object diagram is shown as a class, and the name is underscored, although an object’s name can be shown optionally preceding the class name as: objectname: classname. The object does not have to be named, in which case only the classname is shown underscored. 24

7M822 Object diagram: example 25

7M822 Association Navigation Navigation across an association is, unless otherwise specified, bidirectional. Sometimes, you will want to limit navigation to just one direction. 26

7M822 Dependency Relationship A dependency exits between two elements if changes to the definition of one element (the supplier) may causes changes to the other (the client). With classes: one class sends a message to another; one class has another as part of its data; one class mentions another as a parameter to an operation. 27

7M822 Advanced Class Features 28

7M822 Advanced Class Concepts : Visibility Visibility – class members (attributes, operations) may be specified as: {we have feature f, an attribute or operation that is defined on an object O of class C } + : public {f is public  f is visible to any object and f is inherited by the subclasses of C.} # : protected (f is protected  f is visible only to objects of class C and to objects of C’s subclasses and f is inherited by the subclasses of C.} - : private {f is private  f is visible only to O and f is not inherited by the subclasses of C.} Restricting visibility is the same as restricting accessibility. 29

7M822 Advanced Class Concepts : Scope Individual member data (= attributes) may have: –Class scope : a single copy of an attribute is shared by all instances of a class. –Instance scope : each instance of a class would have its own copy of the attribute. 30

7M822 Class object Objects are abstractions of real-world entities. Objects encapsulate state and represent information. Object’s state is protected. Objects have responsibility. Objects interact by interfaces. 31

7M822 Advanced Class Concepts : Abstract An operation is abstract if it has no implementation. A abstract class cannot have any direct instances. Abstract classes only occur in the context of an inheritance hierarchy. Abstract operations and classes are specified by writing its name in italics. 32

7M822 Advanced Class Concepts : Abstract cont. 33

7M822 Interfaces and Abstract Classes One can vary the interfaces of classes independent of the implementation. A pure interface is a class with no implementation and, therefore has operation declarations but no method bodies an fields. Interfaces are often declared through abstract classes. 34

7M822 Window as Abstract Class 35

7M822 Interfaces and Abstract Class Sub classing is not only the way to do this. For instance Java provides an interface construct, and the compiler checks that the implementing class provides implementations of all the interface’s operations. 36

7M822 Lollipop notation for Interfaces 37

7M822 Aggregation and Composition once more Aggregation is a special form of association that specifies a whole-part relationship between the aggregate (the whole) and a component (the part); aggregation is the part-of relationship. { it is a special form of association in which a collection of objects, each having an independent existence, is associated with an single object} {unfilled diamond} Composition is a form of aggregation with strong ownership and coincident lifetime of the parts by the whole; the part object may belong to only one whole – the parts are usually expected to live and die with the whole. {usually, any deletion of the whole is considered to cascade to the parts}{filled diamond} 38

7M822 Aggregation and Composition once more, cont. 39

7M822 Aggregation and Composition: Example 40

7M822 Alternative notation for Composition 41

7M822 Derived Associations and Attributes Derived associations and attributes can be calculated fro other associations and attributes, respectively, on a class diagram. –For example, an age attribute of a Person can be derived if you know that Person’s date of birth. 42

7M822 Derived Associations and Attributes example 43

7M822 Qualified Associations The qualifier specifies how a specific object at the many end of the association is identified, and may be seen as a kind of key separating all the objects in the association. 44

7M822 Relations and Constraints 45

7M822 Reflexive Associations A class has an association to itself. Example: A directory may contain other directories. DirectoryFile 0..1 parent subdirectory 0..* 10..* 46

7M822 Exclusive-Or Associations Using an eclusive-or (xor) association constraint one can enforce that certain facts exclude each other. 47

7M822 Constraints ConstraintApplies to symbol Meaning complete generalization Specifies that all children in the generalization have been specified and that no additional children are permitted disjoint generalization Specifies that objects of the given parent may have no more than of the given children as a type incomplete generalization Specifies that not all children in the generalization have been specified and that additional children are permitted overlapping generalization Specifies that objects of the given parent may have more than one of the given children as a type xor association Specifies that, over a set of associations, exactly one is manifest for each associated object. 48

7M822 References Sommerville, Ian (2001) Software Engineering, 6 th edition Grady Booch, James Rumbaugh, Ivar Jacobson (2005) The Unified Modeling Language User Guide, 2 nd edition Martin Fowler (2000, 2004 ) Object-Oriented Software Engineering, 2 nd edition; 3 rd edition 49

7M822 Question ? Consider the class Patient and the subtyping of this class into the classes MalePatient and FemalePatient. - how looks the according class diagram, and - which constraint(s) could be mentioned? 50