CSCI-383 Object-Oriented Programming & Design Lecture 10.

Slides:



Advertisements
Similar presentations
UML (cont.) “The Unified Modeling Language User Guide” by G. Booch, J. Rumbaugh and I. Jacobson ● Classes ● Relationships ● Class diagrams ● Examples.
Advertisements

Object-oriented modeling Class/Object Diagrams
Stereotypes Stereotypes provide the capability to create a new kind of modeling element. –They can be used to classify or mark modeling elements. –A type.
1 Generalizations Multiple Inheritance (finishing up Class Design) Class Design – Another Look – Part 11.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System modeling 2.
Inheritance Inheritance Reserved word protected Reserved word super
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
Chapter 14 (Web): Object-Oriented Data Modeling
Class Diagram & Object Diagram
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Object-oriented concepts.
CSE 240 Lecture 4. Quote of the day “A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building,
7M822 UML Class Diagrams advanced concepts 15 September 2008.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 1 Introduction to Object-Oriented Programming.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Modelling classes Drawing a Class Diagram. Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the.
3/15/05H-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Evaluating Class Diagrams Topics include: Cohesion, Coupling Law of Demeter (handout)
PRJ566: PROJECT PLANNING AND MANAGEMENT Class Diagrams.
Chapter 14: Object-Oriented Data Modeling
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
CSSE501 Object-Oriented Development
Object-Oriented Analysis and Design
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
Session 11 The Class Diagram: Aggregation and Generalization Written by Thomas A. Pender Published by Wiley Publishing, Inc. October 12, 2011 Presented.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
Copyright 2001 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix A Object-Oriented.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part V: Design The Design Workflow Design Classes Refining Analysis Relationships.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
Lecture 5: Modelling with Classes. © Lethbridge/Laganière 2005 Chapter 5: Modelling with classes2 5.1 What is UML? The Unified Modelling Language is a.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with 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.
Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented.
© 2011 Pearson Education 1 Chapter 13 (Online): Object-Oriented Databases Modern Database Management 10 th Edition, International Edition Jeffrey A. Hoffer,
Unit 3 Conceptual Data Modeling. Key Concepts Conceptual data modeling process Classes and objects Attributes Identifiers, candidate keys, and primary.
Databases : Data Modeling 2007, Fall Pusan National University Ki-Joune Li.
Domain Modeling Part2: Domain Class Diagram Chapter 4 pp part 2 1.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 13 (Online): Object-Oriented Data Modeling Modern Database Management 10 th Edition.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
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.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
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.
Object Oriented Analysis and Design Class and Object Diagrams.
Database Design – Lecture 12 Object Oriented Database Design cont’d.
Modeling the Static Structure: Relationships ©SoftMoore ConsultingSlide 1.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
UML Part 1: Class Diagrams. Introduction UML stands for Unified Modeling Language. It represents a unification of the concepts and notations presented.
Object Modeling THETOPPERSWAY.COM. Object Modelling Technique(OMT)  Building a model of an application domain and then adding implementation.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Appendix A Object-Oriented Analysis and Design A.1.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
3/1/01H-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Evaluating Class Diagrams Topics include: Cohesion, Coupling Law of Demeter (handout)
Software Modelling Class Diagram. Class Diagrams The main building block in object oriented modeling They are used both for general conceptual modeling.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
EKT472: Object Oriented Programming
Interface, Subclass, and Abstract Class Review
Class diagram Description
Object Oriented Analysis and Design
UML Class Diagram.
Software Engineering Lecture 10.
Advanced Programming Behnam Hatami Fall 2017.
Presentation transcript:

CSCI-383 Object-Oriented Programming & Design Lecture 10

Reflexive Associations It is possible for an association to connect a class to itself

Directionality in Associations Associations are by default bi-directional It is possible to limit the direction of an association by adding an arrow at one end In a specification view this would indicate that a Day has a responsibility to tell which notes it is associated with, but a Note has no corresponding ability to tell which day it is associated with In an implementation view, one would indicate, that Day contains pointer(s) to Note(s), but a Note would not point to any Day

Generalization Specializing a superclass into two or more subclasses. They must follow the isa rule Our idealization of inheritance is captured in a simple rule-of- thumb. Try forming the English sentences ``An A is-a B''. If it “sounds right” to your ear, then A can be made a subclass of B –A dog is-a mammal, and therefore a dog inherits from mammal –A car is-a engine sounds wrong, and therefore inheritance is not natural but a car has-a engine

Generalization Represented using a small triangle pointing to the superclass –The discriminator is a label that describes the criteria used in the specialization

Generalization Generalization captures similarities between several classes in a superclass. Specialization refines and adds differences in subclasses

Inheritance is both Extension and Contraction Because the behavior of a child class is strictly larger than the behavior of the parent, the child is an extension of the parent (larger) Because the child can override behavior to make it fit a specialized situation, the child is a contraction of the parent (smaller)

Avoiding Unnecessary Generalizations Inappropriate hierarchy of classes, which should be instances

Handling Multiple Discriminators What about sharks?

Handling Multiple Discriminators Creating higher-level generalization Results in duplication of features Another possible solution is multiple inheritance. However, it adds too much complexity and is not supported by many OOP languages (e.g., Java, C++) The platypus, a difficult case for single inheritance Why? Egg-laying mammal

Avoiding Having Instances Change Class An instance should never need to change class How to solve this problem?

More Advanced Features: Aggregation Aggregations are special associations that represent ‘part- whole’ relationships –The ‘whole’ side is often called the assembly or the aggregate –This symbol is a shorthand notation association named isPartOf

More Advanced Features: Aggregation Example: “A CPU is part of a computer” Example: “A car has an engine and doors as its parts”

When to Use an Aggregation As a general rule, you can mark an association as an aggregation if the following are true –You can state that the parts ‘are part of’ the aggregate or the aggregate ‘is composed of’ the parts –When something owns or controls the aggregate, then they also own or control the parts

When to Use Aggregation Aggregation vs. attributes –Attributes describe properties of objects (e.g., speed, price, length) –Aggregation describe assemblies of objects Aggregation vs. association –Is a company an aggregation over its employees or is it an association between its employees?

Composition A composition is a strong kind of aggregation –if the aggregate is destroyed, then the parts are destroyed as well –A one-to-one composition often corresponds to a complex attribute. Two alternatives for addresses (i.e., as an attribute or as a composition)

Interfaces An interface is a (abstract) class with no implementation –An interface is implemented (refined) by (different) classes –Example: A portable text editor displays its windows using a window interface that is implemented differently for Windows 95 and Mac OS

Abstract Classes An abstract class is a class without a (full) implementation –Some methods are deferred (i.e., they are not implemented) –The deferred methods are implemented by subclasses only –Example: The window move operation is implemented by using hide and show methods which are implemented by subclasses

Example Class Diagram EXAMPLE: UML class diagram for airline reservation system (done in class)

How to Use Class Diagrams Class diagrams are the backbone of nearly all object-oriented methods. Especially they facilitate code generation The trouble with class diagrams and their rich notation is that they are extremely detailed and therefore confusing –Do not try to use all the notations available to you, if you do not have to –Don’t draw diagrams for everything; instead concentrate on the key areas