Class Diagram Slide 1 1. Objective  Introduces the evolutionary approach for building classes  Explain how to identify objects and attributes of classes.

Slides:



Advertisements
Similar presentations
1 Object-oriented design Part 2: OO tools & UML. 2 CRC cards Design tool & method for discovering classes, responsibilities, & relationships Record on.
Advertisements

Object-oriented modeling Class/Object Diagrams
Unified Modeling Language Philip Liew
©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.
Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.
Slide 1 Chapter 7 Structural Modeling. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Chapter 14 (Web): Object-Oriented Data Modeling
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
7M822 UML Class Diagrams advanced concepts 15 September 2008.
Relational Databases What is a relational database? What would we use one for? What do they look like? How can we describe them? How can you create one?
Chapter 14: Object-Oriented Data Modeling
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Systems Analysis and Design in a Changing World, Fifth Edition
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.
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
5 Systems Analysis and Design in a Changing World, Fourth Edition.
UML Diagrams: Class Diagrams The Static Analysis Model Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Association Class Generalization/Specialization Whole-Part Page More Associations 1.
Systems Analysis and Design in a Changing World, 6th Edition 1 Chapter 4 - Domain Classes.
Lab 04.
Slide 1 Structural Modeling Chapter 7. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Distributed Java Programming Distributed Java Programming Class #2 August 22, 2002.
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.
© 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.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
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.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
Lecture 6: Structural Modeling
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
5 Systems Analysis and Design in a Changing World, Fifth Edition.
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
What is a Structural Model?
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.
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.
Domain Modeling Yonglei Tao.
Object Oriented Analysis and Design Class and Object Diagrams.
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.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
DBMS ER model-2 Week 6-7.
1 SWE Introduction to Software Engineering Lecture 14 – System Modeling.
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.
OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
1 Database Design Sections 6 & 7 First Normal Form (1NF), Second Normal Form (2NF), Unique Identifiers (UID), Third Normal Form (3NF), Arcs, Hierarchies.
Chapter 5: Structural Modeling
5 Systems Analysis and Design in a Changing World, Fourth Edition.
UML Diagrams: Class Diagrams The Static Analysis Model
Lec-4 : Unified Modeling Language (UML)
Chapter 5: Structural Modeling
Class diagram Description
OO Domain Modeling With UML Class Diagrams and CRC Cards
OO Domain Modeling With UML Class Diagrams and CRC Cards
Object Oriented Analysis and Design
Object Oriented Analysis and Design Using the UML
Class Diagram Slide 1.
Class Diagram Slide 1.
UML Class Diagram.
INFS 6225 Object Oriented Systems Analysis & Design
Information System Design
Entity Relationship Model
From Class Diagram to Contract Diagram
Presentation transcript:

Class Diagram Slide 1 1

Objective  Introduces the evolutionary approach for building classes  Explain how to identify objects and attributes of classes  Describe the technique of CRC ‘Class Responsibility and Collaborator’  Explain how classes are related in a class diagram  Explain generalization, association, aggregation and composition  Slide 2 2

OO Structural Modelling The Static View of a system may be described using UML diagrams:  UML Class Diagrams Slide 3 3

From Use Cases to: Objects, Attributes, Operations (methods) - “evolutionary ” Class 1 Class 2 Slide 4 4

Identifying objects  Look for nouns in the SRS (System Requirements Specifications) document  Look for NOUNS in use cases descriptions  A NOUN may be Object Attribute of an object Slide 5 5

Identifying Operations ‘methods’  Look for verbs in the SRS (System Requirements Specifications) document  Look for VERBS in use cases descriptions  A VERB may be translated to an operation or set of operations A method is the code implementation of an operation. Slide 6 6

Objects Slide 7 7

Objects An object is a thing: - student; - transaction; - car; - customer account; - employee; - complex number; - spreadsheet table; - spreadsheet cell; - document; - paragraph; - GUI Combo box - GUI button... and so on. Slide 8 8

Class and Class diagram  Class naming: Use singular names because each class represents a generalized version of a singular object.  Class diagrams are at the core of OO Eng. Slide 9 9

Class and Class diagram  Things naturally fall into categories (computers, automobiles, trees...).  We refer to these categories as classes.  An object class is an abstraction over a set of objects with common: attributes (states) and the services (operations) (methods) provided by each object  Class diagrams provide the representations used by the developers. Slide 10 10

CRC ‘Class Responsibility and Collaborator’  CRC card  Class Responsibility: What the class knows: attributes What the class does: services (operations / methods) Slide 11 11

CRC ‘Class Responsibility and Collaborator’  Class Collaboration: Request for information from another class (what the other class knows as attributes ) Request another class to do some thing (what the other class does as operation ) Slide 12 12

CRC Card What the class knows Or CRC Card Class name ResponsibilityCollaboration  Other classes needed to fulfill class a responsibility Need for Attribute operation does  Slide 13 13

CRC - Class Responsibility CRC Card Student ResponsibilityCollaborator ID What the class knows What the class does Name Department Address Request “Register course” Drop course Request Schedule Slide 14 14

CRC - Class Collaborator  Sometimes a class A has a responsibility to fulfill, but not have enough information to do it.  So class A needs help from another class  See next example Slide 15 15

CRC - Class Collaborator  For example, as you see in students register in courses. To do this, a student needs to know if a spot is available in the course and, if so, he then needs to be added to the course. However, students only have information about themselves (their names and so forth), and not about courses. What the student needs to do is collaborate/interact with the card labeled Course to sign up for a course. Therefore, Course is included in the list of collaborators of Student. Slide 16 16

CRC - Class Collaborator Student Responsibility Collaborator Collaborator Course : ID Class Course Name is needed to Department fulfill class Address Student responsibilities Check course availabilityCourse (Attribute: availability) Need for Request “Register course”Course ( Operation: increment Attribute number of registered student) and/or operation Drop courseCourse (Operation: decrement number of registered student) Request Schedule Slide 17 17

CRC - Class Collaborator     Collaboration takes one of two forms: A request for information or a request to do something. Example Alternative 1: The card Student requests an indication from the card C ourse whether a space is available, a request for information. Student then requests to be added to the C ourse, a request to do something. Alternative 2 : Another way to perform this logic, however, would have been to have Student simply request C ourse to enroll himself ( Student ) into itself ( C ourse). Then have C ourse do the work of determining if a seat is available and, if so, then enrolling the student and, if not, then informing the student that he was not enrolled. Slide 18 18

Types of Operations Operations can be classified into four types, depending on the kind of service requested by clients: 1. constructor: creates a new instance of a class 2. query: is an operation without any side effects; it ccesses the state of an object but does not alter the state 3. update: An operation that alters the state of an object. 19

Class diagrams  Shows relationship between classes  A class diagram may show: Relationship Generalization (inheritance)”is a” “is a kind of” Association (dependency) does “Who does What” “uses” Aggregation“has” “composed of” Composition: Strong aggregation Slide 19 20

Association, aggregation and composition When considering the 3 relationships, association, aggregation and composition, the most general relationship is association, followed by aggregation and, finally, composition. Slide 20 21

Association between classes Who does What Slide 21 22

Multiplicity of Relationships Slide 22 23

Inheritance: is a“is a kind of”  is a association.  Child class ‘subclass’ can inherit attributes and operations from parent class‘superclass’.  Example: An inheritance hierarchy in the animal kingdom Slide 25 24

Class name Attributes Is a Library item Catalogue number Acquisition date Cost Type Status Number of copies Acquire () Catalogue () Dispose () Issue () Return () Library class hierarchy Methods Operations Generalisation Is a Book Author Edition Published item Title Publisher Magazine Year Issue Recorded item Title Medium FilmComputer program Director Date of releaseVersion Distributor Publication date Platform ISBN 25

Library user Name Address Phone Registration # Register () De-register () User class hierarchy Reader Borrower Affiliation Items on loan Max. loans Staff Student DepartmentMajor subject Department phone Home address 26

Hierarchy Diagram ( UML notation ) PERSON Name, Address Phone, Sex Date of Birth ChangeAddress EnquireDOB&Sex ISA CUSTOMER Balance O/Due 30, 60, 90 Credit Rating Date Paid CheckCrRating AgeBalances This kind of arrowhead indicates that this relationship is one of subclassing EMPLOYEE SIN Marital Status No. of Dependants Date Hired Wage Rate GiveRaise CalcMonthPay Slide 28 27

Multiple inheritance  Rather than inheriting the attributes and services from a single parent class, a system which supports multiple inheritance allows object classes to inherit from several super-classes  Can lead to semantic conflicts where attributes/services with the same name in different super-classes have different semantics  Makes class hierarchy reorganisation more complex  Java does not support multiple inheritance Slide 30 28

Example: Multiple inheritance The talking book Book Author Edition Publication date ISBN Voice recording Speaker Duration Recording date Talking book # Tapes Slide 31 29

UML: Associations of regular classes Association:  Who does what relationship  When classes are connected together conceptually, that connection is called an association Who does what Librarian works in Library Slide 32 30

Associations of regular classes - Who does what A manager supervises 1..* employees An employee is supervised by 1 manager Manager 1 Employee supervises 1..* is supervised by Slide 33 31

Multiplicity of an Association  Shows the number of objects from one class that relate with a number of objects in an associated class. Slide 35 32

UML: Multiplicity One class can be relate to another in a:  one-to-one  one-to-many  one-to-one or more  one-to-zero or one  one-to-a bounded interval (one-to-two through twenty)  one-to-exactly n  one-to-a set of choices (one-to-five or eight)  The UML uses an asterisk ( * ) to represent more and to represent many. Slide 36 33

Association and Inheritance. Employee Manager 1 drives supervises 1 Regular Employee * belongs to * * Association: 1 Who does Company Vehicle what Union Slide 37 34

OO: Visibility of attributes or operations  Visibility: specifies the extent to which other classes can use a given class's attributes or operations. Three levels of visibility: ++ ## -- : public level ( usability extends to other classes) : protected level ( usability is open only to classes that inherit from original class) : private level ( only the original class can use the attribute or operation) Slide 38 35

OO: Visibility Ex: Public and private operations in a Hard Disk Slide 39 36

Ex: The character hierarchy  The Character class will have ASCIIcode and type as attributes (type tells the type of the character - normal, italic, bold or underline), and normal(), bold(), italic() and underline() as operations. The Character class children will be: Letter, PunctualSign, SpecialCharacter and Number. Slide 40 37

Ex: Generalization/Specialization Hierarchy Notation for Motor Vehicles Slide 41 38

Ex: Generalization/Specialization Hierarchy Slide 41 39

Object Aggregation  Has-a relationship  Structural: whole/part  Peer relationship Whole & parts objects can exist independently  A special form of association Slide 42 40

Object Aggregation: Peer relationship  Whole & parts objects can exist independently  Example: a bank (whole) has customers (as parts)  Deleting a bank does not cascade deleting customers  Customers can move to another bank  Programming: whole contains an array of parts Slide 43 41

Object Aggregation  Aggregation model shows how classes (which are collections) are composed of other classes.  Similar to the part-of relationship in semantic data models.  A line joins a whole to a part (component) with an open diamond on the line near the whole. Slide 44 42

Object Aggregation Example: An aggregation association in the TV Set system  Every TV has a TV box, screen, speaker(s), resistors, capatitors, transistors, ICs... and possibly a remote control.  Remote control can have these parts: resistors, capatitors, transistors, ICs, battery, keyboard and remote lights. Slide 45 43

Object aggregation Study pack “has” “composed of” 1..* Assignment Credits Course title Number Year Instructor * OHP slides Slides LectureVideotape notes Tape ids. Text Exercises Solutions “part of” #Problems Text Description Diagrams Slide 46 44

Composition  A composite is a strong type of aggregation.  Each component in a composite can belong to just one whole.  The symbol for a composite is the same as the symbol for an aggregation except the diamond is filled. Slide 47 45

Composition- Example 1  Human's outside: Every person has: head, body, arms and legs.  A composite association. In this association each component belongs to exactly one whole.  Whole & parts objects can NOT exist independently Slide 48 46

Composition- Example 2  A bank (whole) has many branches (parts)  Branches can not exist independently of the whole (parts objects can NOT exist independently)  Deleting a bank (whole) cascades deleting branches (parts)  But, if a branch (part) is deleted, the bank (whole) may remain Slide 49 47

University Course Enrollment Design Class Diagram (With Methods) Slide 50 48

Class diagram - Example Reflexive association Association: Patient schedules (zero or more) Appointment Inverse Association : Appointment is associated with only one Patient + Role : Class related to itself Patient “is primary insurance carrier” of another patient (child, spouse) Association: Patient suffers (1 or more) Symptom Inverse Association : Symptom is suffered by (zero or more) Patient Slide 52 49

Example: Slide 50 50