Class Diagrams CS 123/CS 231. Classes in a Class Diagram zClass name onlyExample zWith DetailsExample Class Name attributes methods Bank Account Bank.

Slides:



Advertisements
Similar presentations
Class Relationships Part 1: Composition and Association CS 21a: Introduction to Computing I First Semester,
Advertisements

1 Object-oriented design Part 2: OO tools & UML. 2 CRC cards Design tool & method for discovering classes, responsibilities, & relationships Record on.
Use Case Model. C-S 5462 Use case model describes what the user expects the system to do –functional requirements may describe only the functionalities.
CS 340 UML Class Diagrams. A model is an abstraction of a system, specifying the modeled system from a certain viewpoint and at a certain level of abstraction.
 Kia Manoochehri ◦  Office Hours: 2:30-4:00 M/W ◦ HEC 308 (The Cave)
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
Intro to UML OOP Tirgul UML UML is a graphical representation scheme for modeling OO systems UML today is a unification of various popular notational.
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
UML – Class Diagrams.
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.
CS 106 Introduction to Computer Science I 11 / 19 / 2007 Instructor: Michael Eckmann.
IMSE 11 - UML Class Diagrams
Chapter 2: Entity-Relationship Model (Continued)
© The McGraw-Hill Companies, 2006 Chapter 7 Implementing classes.
Inheritance and Subclasses in Java CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University.
Unified Modeling Language
Relationships. In the Interaction diagrams, we began to look at how classes communicate with one another. Now, we'll focus on the relationships between.
CS 2511 Fall UML Diagram Types  2 Main Types Structure Diagrams ○ Class Diagrams ○ Component Diagrams ○ Object Diagrams Behavior Diagrams ○
 2008 Pearson Education, Inc. All rights reserved (Optional) Software Engineering Case Study: Identifying the Classes in the ATM Requirements.
OBJECT ORIENTED PROGRAMMING LECTURE 12 Instructor: Rashi Garg Coordinator: Gaurav Saxena.
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
Class Relationships and Object Interaction. 8/8/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved.
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.
CSC271 Database Systems Lecture # 25. Summary: Previous Lecture  Structural constraints  Multiplicity  Cardinality  Participation  Connection traps.
UML Class Diagrams 1 These lecture slides are copyright (C) Marty Stepp, They may not be rehosted, sold, or modified without expressed permission.
1 Introduction to Classes and Objects Chapter 3 Introduction to Classes and Objects Chapter 3.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Relationships between classes Using UML
Entity Relationship Diagram (2)
Object Oriented Analysis and Design Class and Object Diagrams.
Class Relationships and Object Interaction CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila.
ACM/JETT Workshop - August 4-5, : Defining Classes in Java.
UML Class Diagram. A class diagram shows 1.Classes 2.The relationships between them.
Database Design – Lecture 12 Object Oriented Database Design cont’d.
1 Class Relationships in C++ CS 123/CS Class Diagram Notation Revisited zMultiplicity zAssociation and Navigability zComposition zAggregation.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
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.
INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify.
Inheritance and Subclasses CS 21a. 6/28/2004 Copyright 2004, by the authors of these slides, and Ateneo de Manila University. All rights reserved L16:
IT 240 Programming Paradigms MS Information Technology Offshore Program Ateneo de Davao Session 3.
Class Diagrams Software Design and Development. Classes in a Class Diagram zClass name onlyExample zWith DetailsExample Class Name attributes methods.
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.
Software Modelling Class Diagram. Class Diagrams The main building block in object oriented modeling They are used both for general conceptual modeling.
1 Chapter 13: Class Diagram Chapter 19 in Applying UML and Patterns Book.
Chapter 12 – Object-Oriented Design
Entity-Relationship Model
Class Relationships in C++
Object-Orientated Analysis, Design and Programming
Unified Modeling Language
UML Class Diagrams (more notation)
Entity-Relationship Model
Class Diagram Details CS 124.
CSC 205 Java Programming II
Showing Relationships in UML
Chapter 18: Refining Analysis Relationships
Domain Class Diagram Chapter 4 Part 2 pp
Software Engineering Lecture #11.
Unified Modelling Language
Understand and Use Object Oriented Methods
Chapter 6: Entity-Relationship Model
Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the.
Object Oriented System Design Class Diagrams
Chapter 11: Class Diagram
Warmup Which of the 4 sorting algorithms uses recursion?
Presentation transcript:

Class Diagrams CS 123/CS 231

Classes in a Class Diagram zClass name onlyExample zWith DetailsExample Class Name attributes methods Bank Account Bank Account double balance deposit() withdraw()

Relationships zInheritance (arrow) Õexample: between Secretary and Employee zComposition/Aggregation (diamond) Õexample: between Car and Wheel zAssociation (line) Õexample: between Borrower and Book

Inheritance Secretary Employee public class Secretary extends Employee { … }

Composition/Aggregation Car Wheel 4 w[] public class Car { Wheel w[];... public Car() { w = new Wheel[4]; … }... } Note: [ ] in diagram is sometimes left out since w does not need to be an array

Association BorrowerBook currBorrbk[] 31 public class Borrower { Book bk[]; … public Borrower() { bk = new Book[3]; } public class Book { Borrower currBorr; … }

Notational Details zCardinality ÕSpecifies the number of objects that may participate in the relationship zRoles and Navigability ÕSpecifies relationship name and access zAggregation versus Composition zDependencies

Cardinality zAlso known as multiplicity ÕExact number (mandatory) ÕRange (e.g., 0..5) Õ* (many-valued) zSpecifies the number of objects that may be associated with an object of the other class zFor associations, multiplicity is specified on both participants

Roles and Navigability zRole name placed on the side of a participant zLet A and B be associated classes and let rrr be the role specified on B’s side Õrrr is the role of B in the relationship Õrrr is a member in class A Õrrr refers to one or more (depending on multiplicity) B objects zAn arrowhead indicates the ability to access B participant(s) from A

Uni-directional Navigability PriceChecker getPrice() pc FastFood Counter public class FastFoodCounter { PriceChecker pc; … public void add( … ) { … double pr = pc.getPrice(); … } … } public class PriceChecker { // no access to counter }

Bi-directional Navigability BorrowerBook currBorrbk[] 31 public class Borrower { Book bk[]; … public Borrower() { bk = new Book[3]; } public class Book { Borrower currBorr; … } Note: double arrowheads may be omitted (bi-directional navigability assumed)

Aggregation versus Composition zPart-of relationships zAggregation ÕPart may be independent of the whole but the whole requires the part ÕUnfilled diamond zComposition (“stronger” form of aggregation) ÕPart is created and destroyed with the whole ÕFilled diamond zDefinitions and distinctions between aggregation and composition still “under debate”

Mandatory Parts Car Wheel 4 wheels public class Car { private Wheel wheels[4]; // wheel objects are created externally... public Car(Wheel w1, Wheel w2, … ) … // wheels required in constructor // w1, w2, … will be checked for null values }

Dependencies zSome classes use other classes but are not related to them in ways previously discussed xNot relationships in the sense that participants do not become attributes in another class zMost common example: ÕAs local variables in (or arguments to) a method of the class

Dependency Example Parser getOrder() uses Restaurant processOrders() public class Restaurant { … public void processOrders() { Parser p = new Parser(…); // call getOrder() in this method } … }