Modeling the Static Structure: Relationships ©SoftMoore ConsultingSlide 1.

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
Object-Oriented Analysis and Design: Object Modeling – Class Diagrams
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.
UML – Class Diagrams.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
Chapter 14 (Web): Object-Oriented Data Modeling
UML Class Diagram and Packages
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 
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix.
7M822 UML Class Diagrams advanced concepts 15 September 2008.
Chapter 4: Object-Oriented Data Modeling
Chapter 10 Classes Continued
7M822 UML Class Diagrams advanced concepts 14 October 2010.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation (Adapted) Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra,
PRJ566: PROJECT PLANNING AND MANAGEMENT Class Diagrams.
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.
Lawrence ChungCS6359.0T1: Module 41 Module 4: Relationships.
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.
Introduction to the Unified Modeling Language “The act of drawing a diagram does not constitute analysis or design. … Still, having a well-defined and.
Copyright 2001 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix A Object-Oriented.
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.
Systems Analysis and Design in a Changing World, 6th Edition 1 Chapter 4 - Domain Classes.
Lab 04.
Systems Analysis and Design in a Changing World, 6th Edition 1 Chapter 4 Domain Classes.
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.
© 2011 Pearson Education 1 Chapter 13 (Online): Object-Oriented Databases Modern Database Management 10 th Edition, International Edition Jeffrey A. Hoffer,
7-1 © Prentice Hall, 2004 Chapter 7: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
7-1 © Prentice Hall, 2007 Chapter 7: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 15: Object-Oriented Data Modeling Modern Database Management 9 h Edition Jeffrey A.
Unit 3 Conceptual Data Modeling. Key Concepts Conceptual data modeling process Classes and objects Attributes Identifiers, candidate keys, and primary.
7-1 © Prentice Hall, 2007 Week 5: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
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.
® 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.
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.
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.
Object-Oriented Data Modeling
Design Model Lecture p6 T120B pavasario sem.
Relationships Relationships between objects and between classes.
Class Modeling Design Class diagram. Classes The term “class ” refers to a group of objects that share a common attributes and common behaviour (operations).
 Week08.  Review Schedule Weeks 8-14  This week o Review last class o Introduce Class Diagrams o ICE-03 Sheridan SYST Engineering Quality Systems.
Java Programming Dr. Randy Kaplan. Abstract Classes and Methods.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
UML Class Diagram. A class diagram shows 1.Classes 2.The relationships between them.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
UML Part 1: Class Diagrams. Introduction UML stands for Unified Modeling Language. It represents a unification of the concepts and notations presented.
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.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi © 2013 Pearson.
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.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Appendix A Object-Oriented Analysis and Design A.1.
Object-Oriented Modeling
Object-Oriented Modeling with UML
UML Class Diagrams: Basic Concepts
Object Oriented Analysis and Design
Lec 3: Object-Oriented Data Modeling
Software Engineering Lecture #11.
Chapter 20 Object-Oriented Analysis and Design
Presentation transcript:

Modeling the Static Structure: Relationships ©SoftMoore ConsultingSlide 1

Class Relationships Association – general relationship Aggregation – whole/part relationship ©SoftMoore ConsultingSlide 2 Class1Class2 Aggregate Part

Class Relationships (continued) Inheritance – generalization/specialization relationship Dependency – general dependency between classes ©SoftMoore ConsultingSlide 3 Superclass Subclass Dependent Class Independent Class

Reflexive Associations A reflexive association does not imply that an object instance is related to itself. ©SoftMoore ConsultingSlide 4 : Person name = “John” : Person name = “Jane” is-married-to Person is-married-to Class Level Object Level

Multiplicity of Associations Multiplicity is a constraint on an association that specifies how many instances of one class may relate to a single instance of another class. Examples: –a workstation has 1 or more windows –a car has 2 or 4 doors –a person works for 0 or more companies Multiplicity is indicated by text expressions at each end of the association. ©SoftMoore ConsultingSlide 5

Displaying Multiplicity ©SoftMoore ConsultingSlide 6 Class 0..1 Optional (zero or one) Class 1 Exactly one Class * Many (zero or more) Class 1..* One or more Class Unspecified Class 1..4, 7 Numerically specified

One-to-Many (1:N) Associations A customer can place many (zero or more) orders, but each order is associated with only one customer. ©SoftMoore ConsultingSlide 7 Customer c1 : Customer c2 : Customer c3 : Customer Order o1 : Order o2 : Order o3 : Order o4 : Order places 1 * Class Level Object Level

One-to-One (1:1) Associations Each elevator has exactly one door, and each door is part of one elevator. ©SoftMoore ConsultingSlide 8 Elevator e1 : Elevator e2 : Elevator e3 : Elevator Door d1 : Door d2 : Door d3 : Door 11 Class Level Object Level

Many-to-Many (M:N) Associations A number of stock items in inventory are supplied by more than one vendor, and vendors often supply more than one stock item. ©SoftMoore ConsultingSlide 9 VendorStock s1 : Stock s2 : Stock s3 : Stock s4 : Stock supplies ** Class Level Object Level v1 : Vendor v2 : Vendor v3 : Vendor v4 : Vendor

Implementing Multiplicity Multiplicity of one is usually implemented using –a reference or pointer in a programming language –a foreign key in a relational database –a combination of the above Multiplicity of many is usually implemented using an array or a container class (e.g., list or vector). ©SoftMoore ConsultingSlide 10

Example: Implementing Multiplicity ©SoftMoore ConsultingSlide 11 CustomerOrder 1 * class Customer { Order[] orders;... } class Order { Customer cust;... } custorders could be a list or set of orders instead of an array

Role Names Each end of an association is a role. A role name may be used to identify how a class at one end of an association participates in the association. Roles provide a way of viewing a binary association as a traversal from one object to a set of associated objects. ©SoftMoore ConsultingSlide 12 CompanyPerson works-for employeeemployer

Aggregation Aggregation is a special kind of association used to represent a “whole/part” or “has-a” relationship among classes. Aggregation is specified by adorning an association with a small open diamond at the whole (aggregate) end of the relationship. ©SoftMoore ConsultingSlide 13 OrderLineItem 1 *

Using Aggregation Aggregation is a special kind of association –asymmetric relationship –transitive relationship –stronger coupling –additional semantics Behavior (copy, delete, etc.) is often propagated across an aggregation but not across an ordinary association. The decision to use aggregation is a matter of judgment. When in doubt, use ordinary association. ©SoftMoore ConsultingSlide 14

Generalization Generalization is a relationship between a more general class (the superclass) and a more specialized class (the subclass), in which objects of the subclass are substitutable in any context that requires an object of the superclass. Generalization expresses the “is-a-kind-of” relationship. A subclass inherits the attributes, operations, methods, and relationships of its superclass. ©SoftMoore ConsultingSlide 15

Notation for Generalization Graphically, generalization is rendered as a directed line from the subclass to its superclass with a large, open arrowhead pointing toward the superclass. ©SoftMoore ConsultingSlide 16 MouseEvent Event

Using Generalization The ability to define superclass/subclass relationships is a fundamental concept in using an object-oriented approach to software development. Generalizations can be defined at multiple levels, giving rise to an inheritance hierarchy. They are transitive across multiple levels. Inheritance hierarchies with “too many” levels of subclassing can be difficult to understand. Six or more levels would probably be excessive for most applications. ©SoftMoore ConsultingSlide 17

Using Generalization (continued) ©SoftMoore ConsultingSlide 18 “It is true that an object-oriented language or notation needs the concept of inheritance to be fully object- oriented. But that doesn’t mean that you have to use inheritance on every problem. The real essence of object-oriented analysis is not inheritance but thinking in terms of objects. – James Rumbaugh [JOOP, Nov/Dec 1991]

Overriding Methods An operation in a subclass that has the same signature as an operation in a superclass overrides (rather than inherits) the method from the superclass. In effect, the subclass has the same operation but supplies its own method. ©SoftMoore ConsultingSlide 19 C1 operation1() operation2() C2 operation1() class C2 overrides the method for operation1()

Abstract Class An abstract class is a class for which object instances may not be created. An abstract class is defined only for the purpose of deriving subclasses; it encapsulates commonality for all descendant classes but may not be used for declaring objects. An abstract class is specified by writing its name in italics. ©SoftMoore ConsultingSlide 20 Shape

Abstract Operation An abstract operation defines the signature of an operation whose corresponding method does not exist or is incomplete. An abstract operation may have a “default” method that implements common functionality. A class with one or more abstract operations is an abstract class; no object instances are permitted. As with classes, an abstract operation is specified by writing its signature in italics. ©SoftMoore ConsultingSlide 21

Concrete Class A concrete class is a class for which it is possible to declare object instances. A concrete class derived from an abstract class must provide an implementation (method) for each abstract operation. The abstract operation imposes an obligation on concrete subclasses to provide the corresponding method. ©SoftMoore ConsultingSlide 22

Example: Abstract Class ©SoftMoore ConsultingSlide 23 Shape origin color lineStyle draw() erase() move() Rectangle corner draw() erase() Circle radius draw() erase()

Using Abstract Classes and Operations Minimize the overriding of non-abstract methods. In general, either an operation should be declared as abstract, or else its method should be inherited without overriding. Minimize inheritance from classes that are not abstract. ©SoftMoore ConsultingSlide 24 “Make non-leaf classes abstract.” – Scott Meyers