III. Class and Object Diagrams



Similar documents
III. Class and Object Diagrams

Object Interaction. Object Diagrams. Object Diagrams Object

Lectures 2 & 3: Introduction to Modeling & UML. Getting started

IV. The (Extended) Entity-Relationship Model

XV. The Entity-Relationship Model

11 November

Object Oriented Software Models

Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model

Getting Started With UML Class Modeling. An Oracle White Paper May 2007

Chapter 8 The Enhanced Entity- Relationship (EER) Model

How To Design Software

Software Engineering. System Models. Based on Software Engineering, 7 th Edition by Ian Sommerville

Génie Logiciel et Gestion de Projets. Software Requirements Engineering

CSC 742 Database Management Systems

Part 7: Object Oriented Databases

Questions? Assignment. Techniques for Gathering Requirements. Gathering and Analysing Requirements

Lecture 12: Entity Relationship Modelling

II. Conceptual Modeling

Database Design Methodology

UML Class Diagrams. Lesson Objectives

Java (12 Weeks) Introduction to Java Programming Language

ATM Case Study OBJECTIVES Pearson Education, Inc. All rights reserved Pearson Education, Inc. All rights reserved.

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #5: En-ty/Rela-onal Models- - - Part 1

An Introduction To UML Class Diagrams Classes

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur

Business Definitions for Data Management Professionals

2. Conceptual Modeling using the Entity-Relationship Model

A terminology model approach for defining and managing statistical metadata

History OOP languages Year Language 1967 Simula Smalltalk

The Entity-Relationship Model

Agile Software Development

THE ENTITY- RELATIONSHIP (ER) MODEL CHAPTER 7 (6/E) CHAPTER 3 (5/E)

The UML Class Diagram

not necessarily strictly sequential feedback loops exist, i.e. may need to revisit earlier stages during a later stage

The MDM (Measurement Data Management) system environment

Best of Both Worlds - A Mapping from EXPRESS-G to UML

CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards

Applying Object-Oriented Principles to the Analysis and Design of Learning Objects

Requirement Analysis & Conceptual Database Design. Problem analysis Entity Relationship notation Integrity constraints Generalization

Database Design Methodology

LAB 3: Introduction to Domain Modeling and Class Diagram

Object Oriented Design

ER modelling, Weak Entities, Class Hierarchies, Aggregation

UML Modeling Guidelines

The Entity-Relationship Model


Software Development: An Introduction

Lecture 6: Requirements Modeling II. The Entity Relationship Model

Exercise 1: Relational Model

Chapter 2: Entity-Relationship Model. E-R R Diagrams

IES - Introduction to Software Engineering

UML FOR OBJECTIVE-C. Excel Software

Ontological Representations of Software Patterns

Modern Systems Analysis and Design

Umbrello UML Modeller Handbook

Software Requirements Specification of A University Class Scheduler

Chapter 3. Data Modeling Using the Entity-Relationship (ER) Model

System Modeling / Class Diagra Diagr m a Week 6

Exercise 8: SRS - Student Registration System

1 Class Diagrams and Entity Relationship Diagrams (ERD)

Object models and Databases. Contents

The Interface Concept

Chapter 2: Entity-Relationship Model. Entity Sets. " Example: specific person, company, event, plant

SysML Modelling Language explained

Appendix... B. The Object Constraint

Checking Access to Protected Members in the Java Virtual Machine

Object-Oriented Data Modeling

7.1 The Information system

Information systems modelling UML and service description languages

Home Assignment 4 OCL

Course Code and Name Year - Semester. Number of marks

Accounting and Settlement: Technical Information

Guide to writing the narrative document Investors, entrepreneurs and self-employed workers. General information

BCS THE CHARTERED INSTITUTE FOR IT BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. September 2013 EXAMINERS REPORT

Case Study: Design and Implementation of an Ordering system using UML, Formal specification and Java Builder

SAMPLE FINAL EXAMINATION SPRING SESSION 2015

PHP Code Design. The data structure of a relational database can be represented with a Data Model diagram, also called an Entity-Relation diagram.

Object-Oriented Systems Analysis and Design

Meta Model Based Integration of Role-Based and Discretionary Access Control Using Path Expressions

Use Case Diagrams. Tutorial

Design and UML Class Diagrams

EXAM. Exam #3. Math 1430, Spring April 21, 2001 ANSWERS

Case studies: Outline. Requirement Engineering. Case Study: Automated Banking System. UML and Case Studies ITNP090 - Object Oriented Software Design

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

Tool Support for Software Variability Management and Product Derivation in Software Product Lines

Programming Language Constructs as Basis for Software Architectures

A DOCUMENT MANAGEMENT SYSTEM MODELING

Stock Manager: An Analysis Pattern for Inventories

Graphical Systems Modeling with UML / SysML Class diagrams

On General-purpose Textual Modeling Languages. On General-purpose Textual Modeling Languages

Offline Payment Methods

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

Online Application Steps and Helpful Hints. Under Borrower: If you select a Marital Status of Married, you will need to mark Yes for Joint Credit.

Transcription:

III. Class and Object Diagrams Classes, Attributes and Operations Objects and Multi-objects Generalization and Inheritance Associations and Multiplicity Aggregation and Composition Business Objects and Rules 2004 John Mylopoulos Class Diagrams -- 1 Classes A class describes a group of objects with similar properties (attributes), common behaviour (operations), common relationships to other objects, and common meaning ( semantics ). Finding classes: Listen to the domain experts ( the people who know the domain you are modeling!) Class Diagrams -- 2

Diagrammatic Notation for Classes Modeling the real world Attributes (optional) StaffMember staffname CalculateBonus() ChangeGrade() Name (mandatory) Operations (optional) Class Diagrams -- 3 System Classes This is a Java class to be included in the design of the new system StaffMember staffname CalculateBonus() ChangeGrade() Class Diagrams -- 4

Attributes Each class can have attributes which represent useful information about instances of a class. Each attribute has a type. For example, Campaign has attributes title and datepaid. Campaign title: String datepaid: Date Class Diagrams -- 5 Objects are Class Instances SaveTheKids:Campaign title: Save the kids datepaid: 28/01/02 Class Diagrams -- 6

Object Diagrams Jaelson:Instructor :Student BillClinton: Monica:Student someone: :Course courseno: csc340" description: OOAD" Class Diagrams -- 7 Multiobjects A multiobject is a set of objects, with an undefined number of elements p2:instructor c1:course c2:course c3:course :Student :Student Multiobjects Class Diagrams -- 8

Operations Often derived from action verbs in the description of the application. Operations describe what can be done with the instances of a class. Class Diagrams -- 9 Operations Campaign Title:String CampaignStartDate:Date CampaignFinishDate:Date EstimatedCost:Money ActualCost:Money CompletionDate:Date DatePaid:Date Completed(CompletionDate:Date, ActualCost:Money) SetFinishDate(FinishDate:Date) RecordPayment(DatePaid:Date) CostDifference():Money Class Diagrams -- 10

Visibility As with Java, attributes and operations can be declared with different visibility modes: + public: any class can use the feature (attribute or operation); # protected: any descendant of the class can use the feature; - private: only the class itself - can use the feature. public private protected Staff name : String passwd : String dateofb : Date ChangePasswd() Include() Class Diagrams -- 11 Relationships Classes and objects do not exist in isolation from one another A relationship represents a connection among things. In UML, there are different types of relationships: Generalization Association Aggregation Composition more Class Diagrams -- 12

Generalization StaffMember staff#:integer name:string startdate:date grade Hire() ChangeGrade() CalculateBonus() Superclass or parent Subclasses or children AdminStaff Hire() CalculateBonus() CreativeStaff qualifications Hire() CalculateBonus() Class Diagrams -- 13 Inheritance of attributes Inheritance of operations Inheritance Overriding inherited attributes or operations. Class Diagrams -- 14

Advert Finding Inheritance Hoarding * Advert Press Advert Video Advert *Billboard Newspaper Advert Magazine Advert Class Diagrams -- 15 Finding Inheritance, Bottom Up Book title author publisher ISBN DeweyCode acquisition# Loan() Return() RecordCD title catalogue# publisher artist acquisition# Loan() Return() Class Diagrams -- 16

...Better! LoanItem title acquisition# Loan() Return() All classes in this diagram model real world entities Book Author DeweyCode publisher ISBN Record artist catalogue# recordco Class Diagrams -- 17 Generalization Notation Possibly overlapping Maria is both Lecturer and Student Mutually exclusive a lecturer can t be a student and vice versa Person Person Student Lecturer Student Lecturer Class Diagrams -- 18

Classification This is the relationship between an object and the classes of which it is an instance. Traditional object models assume that classification is single and static. Multiple classification allows an object to be an instance of several classes that are not is-a related to each other; for example, Maria may be an instance of GradStudent and Employee. Dynamic classification allows an object to change its type during its lifetime. Class Diagrams -- 19 Multiple Classification Male TA Female sex <<mandatory>> student Person Student role <<dynamic>> Professor Staff Class Diagrams -- 20

Association Relationships name StaffMemder name staff# startdate qualification manages manager Campaign title startdate estimatedcost role Class Diagrams -- 21 Association Multiplicity How many instances of a class can participate in an association of a particular type? StaffMemder name staff# startdate qualification manages 1 0..* Campaign title startdate estimatedcost A staff member can manage zero or more campaigns Each campaign is managed by exactly one staff member Class Diagrams -- 22

Multiplicities Some examples of specifying multiplicity: Optional (0 or 1) 0..1 Exactly one 1 = 1..1 Zero or more 0..* = * One or more 1..* A range of values 1..5 A set of ranges 1..3,7..10,15,19..* Class Diagrams -- 23 Direction of an Association StaffMember name staff# startdate qualification manages Campaign title startdate estimatedcost Class Diagrams -- 24

Association Navigation: Uni-Directional Associations PersonName Telephone# Class Diagrams -- 25 Associations and Roles Company * 1..* Person employer hires employee supervisor 1 worker * Class Diagrams -- 26

Association Classes Company * employer hires 1..* employee Person Job description salary Can t have the same person work for the same company more than once! Class Diagrams -- 27 Aggregation Relationship Campaign 1 contains * Advert Class Diagrams -- 28

Composition Relationship A composition relationship implies strong ownership of the part by the whole. For example, the relationship between a person and her head is a composition relationship, and so is the relationship between a car and its engine. In a composition relationship, the whole is responsible for the disposition of its parts, i.e. the composite must manage the creation and destruction of its parts. Class Diagrams -- 29 An Example Order -date: Date -code: Integer -total: Currency +Confirm() +Cancel() -Total():Currency 1 * OrderItem -quantity: Integer -price: Currency * 1 Product Class Diagrams -- 30

Another Example composition 1..1 Engine 1..* Car 1..1 0..1 0..1 0..1 Train aggregation 1..1 driver Person 1..1 driver Class Diagrams -- 31 Object Diagrams, Again Company 1 employer hires 1..* employee Person IBM:Company hires Jack: Person name:ibm Canada addr:235 Eglinton hires Xerox:Company name:xerox Canada addr:2 Bloor hires Not allowed! Jeff: Person Class Diagrams -- 32

Business Objects and Rules Business objects and rules document -- in a structured way -- a class diagram. Such a documentation is also called data dictionary. A business rule can be: an integrity constraint on the data of the application, a derivation rule, whereby information can be derived from other information within a class diagram. Class Diagrams -- 33 Examples of Business Objects Classes i Description Attributes Identifier EMPLOYEE Employee working in the Code, Surname, Code company. Salary, Age PROJECT Company project on which employees are working. Name, Budget, ReleaseDate Name............ Associations Description Classes Entities involved Attributes MANAGEMENT Associate a manager with a department. Employee (0,1), Department (1,1) MEMBERSHIP Associate an employee with a department. Employee (0,1) Department (1,N)............ StartDate Class Diagrams -- 34

Examples of Business Rules Constraints (BR1) The manager of a department must belong to that department. (BR2) An employee must not have a salary greater than that of the manager of the department to which he or she belongs. (BR3) A department of the Rome branch must be managed by an employee with more than 10 years employment with the company. (BR4) An employee who does not belong to a particular department must not participate in any project.... Derivations (BR5) The budget for a project is obtained by multiplying the sum of the salaries of the employees who are working on it by 3.... Class Diagrams -- 35 Additional Readings [Booch99] Booch, G. et al. The Unified Modeling Language User Guide, Addison-Wesley, 1999. (Chapters 4, 5, 8, 9, 10.) [Fowler97] Fowler, M. Analysis Patterns: Reusable Object Models, Addison-Wesley, 1997. Class Diagrams -- 36