ACS-3913 Ron McFadyen 1. UML Notation for Class diagrams Object diagrams

Similar documents
Decorator. The Decorator pattern gives a mechanism without using inheritance.

Class Diagram. Classes consist of. Note that class diagrams contain only classes, not objects.

Class Diagram. Classes consist of. Note that class diagrams contain only classes, not objects.

administrivia today UML start design patterns Tuesday, September 28, 2010

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

Object Oriented Methods with UML

S T R U C T U R A L M O D E L I N G ( M O D E L I N G A S Y S T E M ' S L O G I C A L S T R U C T U R E U S I N G C L A S S E S A N D C L A S S D I A

Chapter 2: Entity-Relationship Model

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

The Unified Modeling Language. Asst.Prof.Dr. Supakit Nootyaskool IT-KMITL

Unified Modeling Language (UML)

Chapter 8: Enhanced ER Model

Introduction to Software Engineering. 5. Modeling Objects and Classes

Data Analysis 1. Chapter 2.1 V3.1. Napier University Dr Gordon Russell

COMP 354: INTRODUCTION TO SOFTWARE ENGINEERING

COSC 3351 Software Design. An Introduction to UML (I)

Entity Relationship Modelling

Ch 9: Mapping EER to Relational. Follow a seven-step algorithm to convert the basic ER model constructs into relations steps 1-7

Chapter 6: Entity-Relationship Model

Class modelling (part 2)

course 3 Levels of Database Design CSCI 403 Database Management Mines Courses ERD Attributes Entities title 9/26/2018

Chapter 6: Entity-Relationship Model

Intro to DB CHAPTER 6

Unified Modeling Language (UML) Class Diagram

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

Conceptual Database Design. COSC 304 Introduction to Database Systems. Entity-Relationship Modeling. Entity-Relationship Modeling

Introducing the UML Eng. Mohammed T. Abo Alroos

Database Systems. A Practical Approach to Design, Implementation, and Management. Database Systems. Thomas Connolly Carolyn Begg

Module 2 : Entity-Relationship Model 15

Chapter 10 Object-Oriented Design Principles

Class modelling (part 2)

Object-Oriented Systems Development: Using the Unified Modeling Language

University of Calgary Department of Electrical and Computer Engineering. SENG : Object Oriented Analysis and Design Behrouz Homayoun Far

OO Techniques & UML Class Diagrams

UML Tutorial. Unified Modeling Language UML Tutorial

LABORATORY 1 REVISION

UML Fundamental. OutLine. NetFusion Tech. Co., Ltd. Jack Lee. Use-case diagram Class diagram Sequence diagram

Basic Structural Modeling. Copyright Joey Paquet,

12 Tutorial on UML. TIMe TIMe Electronic Textbook

Unified Modeling Language (UML)

Software Design Models, Tools & Processes. Lecture 3: Addendum Cecilia Mascolo

Object-Oriented and Classical Software Engineering

UML class diagrams. Nigel Goddard. School of Informatics University of Edinburgh

Chapter 2: The Object-Oriented Design Process

Object-Oriented Systems Analysis and Design Using UML

Chapter 8 The Enhanced Entity- Relationship (EER) Model

Chapter (4) Enhanced Entity-Relationship and Object Modeling

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

Information Technology Audit & Cyber Security

CS111: PROGRAMMING LANGUAGE II

Experiment no 4 Study of Class Diagram in Rational Rose

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Chapter 7: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

Chapter 9: Relational DB Design byer/eer to Relational Mapping Relational Database Design Using ER-to- Relational Mapping Mapping EER Model

OO System Models Static Views

CSC9T4: Object Modelling, principles of OO design and implementation

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

Using High-Level Conceptual Data Models for Database Design A Sample Database Application Entity Types, Entity Sets, Attributes, and Keys

Introduction to Unified Modelling Language (UML)

Object Oriented Design. Program Design. Analysis Phase. Part 2. Analysis Design Implementation. Functional Specification

UML Class Diagrams Revisited

Roadmap of This Lecture. Weak Entity Sets Extended E-R Features Reduction to Relation Schemas Database Design UML*

Relationships. Association Aggregation/Composition Multiplicity Dependencies

Chapter 7: Entity-Relationship Model

COSC 304 Introduction to Database Systems. Entity-Relationship Modeling

Architecture and the UML

MSO Exam November 7, 2016, 13:30 15:30, Educ-Gamma

COMP Instructor: Dimitris Papadias WWW page:

From Analysis to Design. LTOOD/OOAD Verified Software Systems

ER modeling. Lecture 4

ER to Relational Mapping

MIS Database Systems Entity-Relationship Model.

Modeling with UML. (1) Use Case Diagram. (2) Class Diagram. (3) Interaction Diagram. (4) State Diagram

Database Applications (15-415)

Object Modeling. Entity-Relationship (ER) diagrams (1976) Object Modelling Technique (OMT) diagrams (1991)

Chapter 2: Entity-Relationship Model. Entity Sets. Entity Sets customer and loan. Attributes. Relationship Sets. A database can be modeled as:

OOADP/OOSE Re- exam. 23 August Mapping marks onto grades. Answers

2.0.3 attributes: A named property of a class that describes the range of values that the class or its instances (i.e., objects) may hold.

Darshan Institute of Engineering & Technology for Diploma Studies

Chapter 5: Structural Modeling

An Introduction To Object Modeling System Concept for Object Modeling The Overall View Components of UML Diagram

Multiple Choice Questions

The Entity-Relationship Model. Steps in Database Design

Entity-Relationship Model

Ali Khan < Project Name > Design Document. Version 1.0. Group Id: S1. Supervisor Name: Sir.

Computer Science for Engineers

Enhanced Entity- Relationship Models (EER)

UML Is Not a Methodology


BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING

E-R Model. Hi! Here in this lecture we are going to discuss about the E-R Model.

Chapter 7: Entity-Relationship Model

Relational DB Design by ER- and EER-to-Relational Mapping Design & Analysis of Database Systems

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

4. Entity Relationship Model

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

Conceptual Data Modeling and the Entity- Relationship Model. Department of Computer Science Northern Illinois University September 2014

2.0.3 attributes: A named property of a class that describes the range of values that the class or its instances (i.e., objects) may hold.

Major components of ER diagram Practices

Transcription:

ACS-3913 Ron McFadyen 1 UML Notation for Class diagrams Object diagrams

Class Diagram ACS-3913 Ron McFadyen 2 A class diagram begins as a conceptual or analysis class model and evolves to a design class model Used throughout the development process More detail added as time goes by A static view of classes shows structure: data, operations, and associations

Classes ACS-3913 Ron McFadyen 3 Represented by a rectangle with possibly 3 compartments Name Address Customer Customer Name Address Customer getname() checkcreditrating() Customer getname() checkcreditrating()

Classes ACS-3913 Ron McFadyen 4 Some classes are stereotyped: «Singleton» dbfacade Stereotyping dbfacade as singleton conveys substantial information about the class and its behaviour. Some methodologies have 3 stereotypes for analysis classes: boundary, control, entity

Classes ACS-3913 Ron McFadyen 5 Abstract Classes An abstract class is one that is never instantiated. To indicate an abstract class, the class name is given in italics or by using an abstract stereotype. Composite

ACS-3913 Ron McFadyen 6 Attributes an object contains data data fields are defined as part of the Class definition examples: Students have names, addresses, etc; Courses have titles, descriptions, prerequisite information. Student name address Rectangle corner: Point Data type Level of detail present will depend on whether you are in analysis or design, and your purposes at the time

ACS-3913 Ron McFadyen 7 Attributes To what degree is an attribute visible to other classes? Private Public + Protected # Package ~ Student -name -address

ACS-3913 Ron McFadyen 8 Attributes Default values = Derived values / Multiplicity [ ] Ordering {ordered} Uniqueness {unique} Invoice -date:date = today -/total: Currency -payments[0..]: Currency Student -name -address[1..3] {unique}

ACS-3913 Ron McFadyen 9 Operations. What are the responsibilities of a class? What can it do? Parameters Signature the name, parameters, and return type of the operation Student +getname() +getgpa(term :Term, gpatype: String)

ACS-3913 Ron McFadyen 10 Associations correspond to verbs expressing a relationship between classes example a Library Member borrows a Copy of a Book Multiplicities we indicate via multiplicities the range of allowable cardinalities for participation in an association examples: 1 1.. 0.. 1..3

ACS-3913 Ron McFadyen 11 Associations Names and roles you can name the relationship and indicate how to read it you can give role names for participating objects The name of the relationship and the direction for reading the name Person 1.. Works for 1 employee employer Company The role of a Person in this relationship The role of a Company in this relationship

ACS-3913 Ron McFadyen 12 Associations example: An employee reports to another employee (his/her supervisor) subordinate Employee reports to 0,1 supervisor A reflexive association

ACS-3913 Ron McFadyen 13 Generalization a generalization is a relationship between a general thing (the superclass or parent class) and a more specific thing (the subclass or child class) example: a StaffMember is a specialized kind of LibraryMember a StudentMember is a specialized kind of LibraryMember LibraryMember StaffMember StudentMember

ACS-3913 Ron McFadyen 14 Motivation for partitioning a class into subclasses: subclass has additional attributes of interest subclass has additional associations of interest subclass is operated on, handled, reacted to, or manipulated differently than the superclass or other subclasses

ACS-3913 Ron McFadyen 15 Generalization Multiple subclasses can be grouped to indicate they are related subclasses LibraryMember StaffMember StudentMember It then becomes meaningful to consider certain constraints: complete, incomplete, disjoint, overlapping

ACS-3913 Ron McFadyen 16 Generalization LibraryMember StaffMember StudentMember Inheritance of attributes and behaviour: everything a LibraryMember can do, a StudentMember can do If a LibraryMember can borrow a book, so can a StaffMember and a StudentMember a StaffMember and a StaffMember have all the attributes the LibraryMember has, and possibly more Specialization: there are some things that a specialized class can do that a LibraryMember cannot

ACS-3913 Ron McFadyen 17 Every payment, regardless of whether it is cash, credit, or cheque, has an Amount and it is associated with a Sale Payment Amount: money pays-for 1 Sale Cash Payment Credit Payment Cheque Payment 1 1 1 CreditCard Cheque

ACS-3913 Ron McFadyen 18 Payment Amount: money Cash Payment Credit Payment Cheque Payment The name Payment is italicized - meaning it is an abstract class An abstract class is a class that will never be instantiated; only its subclasses can exist If Payment was not in italics then a Payment could exist that is not a Cash, Credit, or Check payment

ACS-3913 Ron McFadyen 19 What is the difference: Payment Unauthorized Payment Authorized Payment Payment is in 1 PaymentState Unauthorized State Authorized State

ACS-3913 Ron McFadyen 20 Aggregation and Composition both are associations used to denote that an object from one class is part of an object of another class An example of Aggregation: a course is part of a program. The same course could be part of several programs Program Course Suppose the course UML and Patterns is part of both the Software Engineering and the Computer Science programs

ACS-3913 Ron McFadyen 21 Aggregation and Composition Composition is similar to, but stronger than aggregation. If you specify composition, then you are saying that one object owns its parts. Board Square A Board is made up of several Squares. A Square will belong to just one Board. If a Board is deleted, then its Squares are deleted too. What is the multiplicity at the composition end of the association?

ACS-3913 Ron McFadyen 22 Aggregation and Composition Consider Invoices and their Invoice Lines Question: Is the association aggregation or composition?? Invoice? InvoiceLine

Composite Pattern ACS-3913 Ron McFadyen 23 A composite is a group of objects in which some objects contain others; one object may represent groups, and another may represent an individual item, a leaf. We will examine the composite pattern later in the course. At this time, we are many concerned with its structural aspect. Consider the class diagram that follows. What objects does it allow us to instantiate and how will they relate to one another? What is this data structure? What does an instance look like?

Composite Pattern ACS-3913 Ron McFadyen 24 Consider a UML class diagram for menus. Menus may be complex and contain other menus. Waitress MenuComponent count() count() MenuItem Menu components: List count() 1

Composite Pattern ACS-3913 Ron McFadyen 25 An object diagram illustrating a tree a possible main menu comprising several connected objects :Waitress main: Menu coffee: MenuItem breakfast:menu lunch: Menu special: MenuItem reg: MenuItem sandwich: MenuItem soup: MenuItem

Decorator Pattern ACS-3913 Ron McFadyen 26 The decorator pattern allows us to enclose an object inside another object. The enclosing object is called a decorator. The other object is the component, it is the decorated object. The decorator conforms to the interface of the enclosed component and so its presence is transparent to the components clients. The decorator forwards requests to the component, but may perform some processing before/after doing so. We will examine the decorator pattern later in the course. Consider the class diagram that follows. What objects does it allow us to instantiate and how will they relate to one another? What is this data structure? What does an instance look like?

Decorator Pattern ACS-3913 Ron McFadyen 27 UML class diagram sale 1 1 DecoratedReceipt print() 1 What would a typical object diagram look like? Receipt Decorator How does the Decorator pattern differ from the Composite pattern? print() print() other() timeofday productcoupon moneysaved

Class Diagram ACS-3913 Ron McFadyen 28 Navigability This constraint specifies if a direction can be followed whether one can navigate from one type of object to another type of object by following an association path. Student History Bidirectional is default If an association can be navigated then support for that is required In above we say we can navigate from Student to History, but not the other way

Class Diagram ACS-3913 Ron McFadyen 29 Navigability The student class can have an attribute to implement the navigable association: Student -history[0..] : History Course a student will know its courses a student can send a message to a Course object

Class Diagram ACS-3913 Ron McFadyen 30 Association classes Used when there is data or behaviour related to the association Useful for many-to-many associations Student Section A student registers for a section and a section has many students registered

Class Diagram ACS-3913 Ron McFadyen 31 Association classes Suppose we need to store information that describes the association Student Section Enrollment termmark exammark grade gp()

Class Diagram ACS-3913 Ron McFadyen 32 Association classes An association class is an association and it is a class it can participate in associations Student Section Enrollment Exam 0,1 termmark exammark grade gp()

Class Diagram ACS-3913 Ron McFadyen 33 Association classes For a given student and section there can be only one occurrence of Enrollment. This rule is quite strict. Student Section Enrollment Exam 0,1 termmark exammark grade gp()

Class Diagram ACS-3913 Ron McFadyen 34 Association classes In this example we are consider an association between Student and Course. Student Course Exam 0,1 term section grade gp() Enrollment With only one occurrence of enrollment for a given student and course, we would only be keeping the most recent values for term, grade, etc.

Class Diagram ACS-3913 Ron McFadyen 35 Association classes To allow more flexibility, the modeler might promote an association class to a full class, as in: Student 1 1 Course Enrollment Exam 0,1 term section grade gp()

Class Diagram ACS-3913 Ron McFadyen 36 N-ary associations An n-ary association is an association among 3 or more classes Section Student enrollment Term

Class Diagram ACS-3913 Ron McFadyen 37 N-ary associations Each instance of the association is an n-tuple of values from the respective classes. For each association we have one student, one section, one term The multiplicity on a role represents the potential number of instance tuples in the association when the other n-1 values are fixed. Section For a given student and term, we have many sections, Student enrollment Term

Class Diagram N-ary associations Consider a team, goalies, and the season. We could record the performance of each goalie for each team and each season. Year season Team team goalie Player Record goalsfor goalsagainst Wins Losses ties ACS-3913 Ron McFadyen 38

Object Diagram ACS-3913 Ron McFadyen 39 An object diagram is an object graph showing objects (possibly named and including attribute values) and links. A link shows a connection from one object to another.

Objects ACS-3913 Ron McFadyen 40 An individual object (instance of a class) is shown with naming information underlined :sale An unnamed sale object s4:sale A sale object named s4 s4 An object named s4

An object diagram ACS-3913 Ron McFadyen 41 :Waitress main: Menu coffee: MenuItem breakfast:menu lunch: Menu special: MenuItem reg: MenuItem sandwich: MenuItem soup: MenuItem

Interfaces ACS-3913 Ron McFadyen 42 An interface is special type of class that cannot be instantiated. An application can never instantiate an interface. An interface defines a set of public attributes and operations that some class must use There is no behaviour defined, no method coded Some other class inherits the interface and provides the implementation

From Head First ACS-3913 Ron McFadyen 43 public interface Observer { public void update(float temp, float humidity, float pressure); } import java.util.; public class StatisticsDisplay implements Observer { public void update(float temp, float humidity, float pressure) { tempsum += temp; numreadings++; if (temp > maxtemp) { maxtemp = temp; } if (temp < mintemp) { mintemp = temp; } display(); }

From Head First ACS-3913 Ron McFadyen 44 update() <<interface>> Observer Specifies the signature for update but there is no implementation, no code Note : the line is a dashed line! StatisticsDisplay update() implements the update operation there is code here