Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.

Slides:



Advertisements
Similar presentations
Object-oriented modeling Class/Object Diagrams
Advertisements

1 CIS224 Software Projects: Software Engineering and Research Methods Lecture 4 Class Models (Based on Fowler (2004, Chapters 3 & 5) and Stevens and Pooley.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System modeling 2.
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.
Software Engineering COMP 201
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
Essentials of class models. 2 A very simple class model In UML, a class is shown in a class diagram as a rectangle giving its name.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4- 1.
Essentials of interaction diagrams Lecture 23 & 24.
Essentials of interaction diagrams Lecture Outline Collaborations Interaction on collaboration diagrams Sequence diagrams Messages from an object.
Essentials of state and activity diagram Lecture 24.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
IMSE 11 - UML Class Diagrams
MORE ON CLASS MODELS Lecture Outline Aggregation and composition Roles Navigability Qualified association Derived association Constraints Association.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 Class and Object Diagrams PRACTICAL OBJECT-ORIENTED DESIGN WITH.
1 Data Modelling Which data to include in the database.
Modelling classes Drawing a Class Diagram. Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the.
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
Unified Modeling Language
The Unified Modeling Language (UML) Class Diagrams.
Object-Oriented Analysis and Design
Specialization and generalization
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
UML Diagrams: Class Diagrams The Static Analysis Model Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
Lab 04.
Distributed Java Programming Distributed Java Programming Class #2 August 22, 2002.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Unit 1 INTRODUCTION TO MODELING AND CLASS MODEL Ref : L7-UML.PDF.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
INFO 620Lecture #81 Information Systems Analysis and Design Class Diagram Refinement INFO 620 Glenn Booker.
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 03. Classes,
Engineering 5895: Software Design 9/11/01Class Diagrams 1.
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.
The Static Analysis Model Class Diagrams Prof. Hany H. Ammar, CSEE, WVU, and Dept. of Computer Science, Faculty of Computers and Information, Cairo University.
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.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Advanced UML Class Diagrams.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Enhanced Entity-Relationship (EER) Modeling. Slide 4- 2 Chapter Outline EER stands for Enhanced ER or Extended ER EER Model Concepts Includes all modeling.
Object Oriented Analysis and Design Class and Object Diagrams.
Object-Oriented Analysis and Design CHAPTERS 9, 31: DOMAIN MODELS 1.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Object-Oriented Design.
UML Class Diagram notation Indicating relationships between classes SE-2030 Dr. Mark L. Hornick 1.
UML Part 1: Class Diagrams. Introduction UML stands for Unified Modeling Language. It represents a unification of the concepts and notations presented.
Chapter 16: UML Class Diagrams
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
© Shamkant B. Navathe CC Enhanced Entity-Relationship Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
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.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
UML Fundamental Elements. Structural Elements Represent abstractions in our system. Elements that encapsulate the system's set of behaviors. Structural.
Lecture 3 A short revision of ER and EER modelling See R. Elmasri, S.B. Navathe. Fundamentals of Database Systems (third edition) Addison-wesley. Chapter.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 4- 1.
ER Diagrams ● Many different notations are available ● From wikipedia:wikipedia: Entity-relationship modelwikipedia: Entity-relationship model ● How do.
Enhanced Entity-Relationship (EER) Model
Object-Orientated Analysis, Design and Programming
Business System Development
Visit for more Learning Resources
Chapter 11 Object-Oriented Design
Reference: COS240 Syllabus
Seminar 3 UML Class Diagram.
Software Engineering Lecture #11.
Understand and Use Object Oriented Methods
Business Analysis More on Classes Chris Russell O2.41
Enhanced Entity-Relationship (EER) Modeling
Object Oriented System Design Class Diagrams
Presentation transcript:

Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture 20 – More on Class Models 1COMP201 - Software Engineering

Lecture Outline Aggregation and composition Roles Navigability Qualified association Derived association Constraints Association classes Interfaces and abstract classes 2COMP201 - Software Engineering

Aggregation and Composition Aggregation and composition are kinds of association: Instead of just showing that two classes are associated we may choose to show more about what kind of association this is Aggregation and composition are both ways of recording that an object of one class is part of an object of another class. 3COMP201 - Software Engineering

Module is a Part of an HonoursCourse The notation with open diamond, denotes aggregation, which is more general way of denoting a part-whole relationship in UML 4COMP201 - Software Engineering

Aggregation is essentially a conceptual notion: seeing an aggregation in a class model should help you to understand the relationships between the classes at an informal level BUT it does not give you any more formal information about how they must be implemented or what you can do with them Usually we do not name an aggregation association since it is usually “is a part of”. 5COMP201 - Software Engineering Aggregation

Composition Composition is a special kind of aggregation which imposes some further restrictions. In composition association, the whole strongly owns its parts If the whole object is copied or deleted, its parts are copied or deleted with it The multiplicity at the whole end of a composition association must be 1 or 0..1 A part cannot be part of more than one whole by composition 6COMP201 - Software Engineering

Example Noughts and Crosses (Tic-Tac-Toe) Composition is denoted similarly to aggregation, except that the diamond is filled in 7COMP201 - Software Engineering

Examples Consider the following scenarios and determine whether we should use composition or aggregation: The relationship between an Employee and a Team? The relationship between a Wheel and a Car? The relationship between an Account and a Customer? COMP201 - Software Engineering8

Roles Often you can read an association name in both directions (‘is taking’, ’is taken by’) Sometimes, however, it is more readable to have separate names for the roles that the objects play in the association. 9COMP201 - Software Engineering

Association with no Navigability The diagram records that: For each object of class Student there are six objects of class Module which are associated with the Student; For each object of class Module there are some Student objects (the number of students is unspecified) associated with the Module. 10COMP201 - Software Engineering

Navigability We can put an arrow on one or both ends of the association line to represent that it is possible for messages to be sent in the direction of the arrow We say that Module knows about Student, but not vice versa. 11COMP201 - Software Engineering

Qualified Associations Occasionally it is helpful to give finer detail about an association than we have so far. Square is identified relative to the board it’s on by attributes raw and column, each taking a value between 1 and 3 12COMP201 - Software Engineering

Qualified Composition In fact we can combine the qualified association notation with the other association notations For example, we can add back the information that this particular association is a composition 13COMP201 - Software Engineering

Derived Associations Imagine that a student takes a module and a lecturer teaches a module. Do we also have to record that a lecturer teaches students? Is it necessary, or already implied by the other two associations? UML has the concept of derived associations to deal with such situations to emphasise to the designer that there is no need to implement this behaviour directly. 14COMP201 - Software Engineering

Derived Associations A derived association exists automatically once we have implemented the main association A derived association as shown using a slash in front of its name The black triangles indicate which direction of the association the name describes. 15COMP201 - Software Engineering

Constraints A constraint is a condition that must be satisfied by any correct implementation of a design The formal constraints can be written in OCL, the Object Constraint Language (developed by IBM) OCL is intended to be Formal, so that constraints written in it are unambiguous Easy to use, so that every developer can write constraints 16COMP201 - Software Engineering

XOR Constraints Imagine that we know that a Copy is either a Book or a Journal in our design. If we simply have two associations, one between Copy- Book and another between Copy-Journal, this will not rule out the (nonsensical) possibility of having a Copy which is both a Book and a Journal, or with neither.. On the next slide we can see this situation modelled in a class diagram.. COMP201 - Software Engineering17

XOR Constraints COMP201 - Software Engineering18 Can a Copy be both a Book and a Journal; or neither?

XOR Constraints To get round this problem, we may use an xor constraint which is not written in OCL, but is a specially defined constraint in UML. Xor stands for “exclusive or”. If we have two possibilities, A and B, then A xor B means either A or B but not both (this is a widely used concept in computer science). It is also sometimes written as :in logic. COMP201 - Software Engineering19

20 Each Copy object now represents either a copy of Book or a copy of Journal COMP201 - Software Engineering XOR Constraint

Association Classes Sometimes the association between classes itself may need attributes and operations. For example, consider the situation that a Student class is associated with a Module class. Where should the students grade for that module be stored? Is it a part of the Student class? The Module Class? The grade really belongs to the association of these two classes.. 21COMP201 - Software Engineering

Association Classes An association class is both an association and a class. 22COMP201 - Software Engineering

Avoiding an Association Class 23COMP201 - Software Engineering

Interfaces An interface specifies operations of some model element visible outside of the class. In UML2, an interface may specify some attributes and associations. All the elements of such an interface in a class diagram are public. The notation is to use a rectangle just like a class but with a “ >” string. COMP201 - Software Engineering24

Abstract Classes An interface is similar to the idea of an abstract class, which can be modeled in UML by using the word “abstract” on the class icon as a property. An abstract class is one in which, for at least one operation, the implementation of that method is not defined. Thus the class cannot be instantiated. A class where no method has an implementation is essentially an interface that we saw on the previous slide. COMP201 - Software Engineering25

Lecture Key Points We have seen some more features of class diagrams such as Aggregation and composition Navigability Associations Constraints Interfaces Next lecture we will be looking at interaction diagrams and specifically sequence diagrams. COMP201 - Software Engineering26