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,

Slides:



Advertisements
Similar presentations
SEG4110 – Advanced Software Design and Reengineering TOPIC A Review of UML.
Advertisements

UML (cont.) “The Unified Modeling Language User Guide” by G. Booch, J. Rumbaugh and I. Jacobson ● Classes ● Relationships ● Class diagrams ● Examples.
7M822 UML Class Diagrams 7 October 2010.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System modeling 2.
Improved software quality through semantic descriptions (Skutt) Karlstad University Dept. of Computer Science UML introduction A short introduction.
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 1 Introduction to Object-Oriented Programming and.
Class Diagram & Object Diagram
Data and Process Modeling
IMSE 11 - UML Class Diagrams
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 1 Introduction to Object-Oriented Programming and Software Development.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 Class and Object Diagrams PRACTICAL OBJECT-ORIENTED DESIGN WITH.
7M822 UML Class Diagrams advanced concepts 15 September 2008.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
7M822 UML Class Diagrams advanced concepts 14 October 2010.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
©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.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation (Adapted) Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra,
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
Unified Modeling Language
Object-Oriented Analysis and Design
UML Unified Modeling Language. What is UML? Unified Modeling Language (UML) is a standardized, general-purpose modeling language in the field of software.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
CSCI-383 Object-Oriented Programming & Design Lecture 9.
Chapter 5: Modelling with Classes
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 Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
R McFadyen Chapter 7 Conceptual Data Modeling.
Programming in Java Unit 3. Learning outcome:  LO2:Be able to design Java solutions  LO3:Be able to implement Java solutions Assessment criteria: 
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
1 UML Basic Training. UML Basic training2 Agenda  Definitions: requirements, design  Basics of Unified Modeling Language 1.4  SysML.
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.
7-1 © Prentice Hall, 2004 Chapter 7: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
7-1 © Prentice Hall, 2007 Chapter 7: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
7-1 © Prentice Hall, 2007 Week 5: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Systems Analysis & Design 7 th Edition Chapter 5.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
INFO 620Lecture #81 Information Systems Analysis and Design Class Diagram Refinement INFO 620 Glenn Booker.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Modeling system requirements. Purpose of Models Models help an analyst clarify and refine a design. Models help simplify the complexity of information.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Course Instructor: Kashif Ihsan 1. Chapter # 3 2.
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.
 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.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Chapter 5 System Modeling. What is System modeling? System modeling is the process of developing abstract models of a system, with each model presenting.
Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
John D. Bell Polymath for Hire. Polymath?? Merriam Webster (on-line) defines it as: – A person of encyclopedic learning – From the “Greek polymathēs very.
Modelling with Classes Adapted after : Timothy Lethbridge and Robert Laganiere, Object-Oriented Software Engineering – Practical Software Development using.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes Based on Presentations LLOSENG.
Chapter 11 Inheritance © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured and Object-Oriented.
CSCE 240 – Intro to Software Engineering Lecture 3.
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 14 Slide 1 Object-Oriented Design.
UML (Unified Modeling Language)
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Chapter 5: Modelling with Classes
Object-Oriented Analysis and Design
A short introduction to UML Eivind J. Nordby Karlstad University
UML Class Diagrams: Basic Concepts
Chapter 20 Object-Oriented Analysis and Design
Chapter 5: Modelling with Classes
Presentation transcript:

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, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.” -Robert Heinlein

Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes (author’s slides)

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes4 5.1 What is UML? The Unified Modelling Language is a standard graphical language for modelling object oriented software At the end of the 1980s and the beginning of 1990s, the first object- oriented development processes appeared The proliferation of methods and notations tended to cause considerable confusion Two important methodologists Rumbaugh and Booch decided to merge their approaches in —They worked together at the Rational Software Corporation In 1995, another methodologist, Jacobson, joined the team —His work focused on use cases In 1997 the Object Management Group (OMG) started the process of UML standardization

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes5 UML diagrams Class diagrams —describe classes and their relationships Interaction diagrams —show the behaviour of systems in terms of how objects interact with each other State diagrams and activity diagrams —show how systems behave internally Component and deployment diagrams —show how the various components of systems are arranged logically and physically

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes6 UML features It has detailed semantics It has extension mechanisms It has an associated textual language —Object Constraint Language (OCL) The objective of UML is to assist in software development —It is not a methodology

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes7 What constitutes a good model? A model should use a standard notation be understandable by clients and users lead software engineers to have insights about the system provide abstraction Models are used to help create designs to permit analysis and review of those designs. as the core documentation describing the system.

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes8 5.2 Essentials of UML Class Diagrams The main symbols shown on class diagrams are: Classes -represent the types of data themselves Associations -represent linkages between instances of classes Attributes -are simple data found in classes and their instances Operations -represent the functions performed by the classes and their instances Generalizations -group classes into inheritance hierarchies

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes9 Classes A class is simply represented as a box with the name of the class inside The diagram may also show the attributes and operations The complete signature of an operation is: operationName(parameterName: parameterType …): returnType

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes Associations and Multiplicity An association is used to show how two classes are related to each other Symbols indicating multiplicity are shown at each end of the association

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes11 Labelling associations Each association can be labelled, to make explicit the nature of the association

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes12 Analyzing and validating associations One-to-one —For each company, there is exactly one board of directors —A board is the board of only one company —A company must always have a board —A board must always be of some company

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes13 Analyzing and validating associations Many-to-many —A secretary can work for many managers —A manager can have many secretaries —Secretaries can work in pools —Managers can have a group of secretaries —Some managers might have zero secretaries. —Is it possible for a secretary to have, perhaps temporarily, zero managers?

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes14 Analyzing and validating associations One-to-one —For each company, there is exactly one board of directors —A board is the board of only one company —A company must always have a board —A board must always be of some company

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes15 Analyzing and validating associations Avoid unnecessary one-to-one associations Avoid thisdo this

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes16 A more complex example A booking is always for exactly one passenger —no booking with zero passengers —a booking could never involve more than one passenger. A Passenger can have any number of Bookings —a passenger could have no bookings at all —a passenger could have more than one booking

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes17 Association classes Sometimes, an attribute that concerns two associated classes cannot be placed in either of the classes The following are equivalent Registration grade StudentCourseSection ******* Registration grade StudentCourseSection **

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes18 Reflexive associations It is possible for an association to connect a class to itself Course * isMutuallyExclusiveWith * * prerequisite successor *

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes19 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 ** NoteDay

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes Generalization Specializing a superclass into two or more subclasses The discriminator is a label that describes the criteria used in the specialization

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes21 Avoiding unnecessary generalizations RockRecordingBluesRecordingClassicalRecordingJazzRecordingMusicVideo VideoRecording AudioRecordingRecording rockbluesclassicaljazzmusic video videoaudio RecordingCategory * subcategory description Recording * hasCategory subcategory :RecordingCategory 9th Symphony :Recording Let it be :Recording The Beatles Beethoven title artist Inappropriate hierarchy of classes, which should be instances Improved class diagram, with its corresponding instance diagram

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes22 Handling multiple discriminators Creating higher-level generalization

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes23 Using multiple inheritance Using the Player-Role pattern (in Chapter 6) Handling multiple discriminators Animal habitat typeOfFood HerbivoreCarnivoreLandAnimalAquaticAnimal AquaticCarnivoreAquaticHerbivoreLandCarnivoreLandHerbivore

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes24 Avoiding having instances change class Student attendance PartTimeStudentFullTimeStudent An instance should never need to change class

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes Instance Diagrams A link is an instance of an association —In the same way that we say an object is an instance of a class Carla:Employee Ali:Employee Wayne:Employee OOCorp:Company OOCorp's Board: UML inc's Board UML inc:Company Pat:Employee Terry:Employee

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes26 Associations versus generalizations in instance diagrams Associations describe the relationships that will exist between instances at run time. —When you show an instance diagram generated from a class diagram, there will be an instance of both classes joined by an association Generalizations describe relationships between classes in class diagrams. —They do not appear in instance diagrams at all. —An instance of any class should also be considered to be an instance of each of that class’s superclasses

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 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 **** ****** Region VehiclePart Country Vehicle

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes28 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 it also owns or controls the parts

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes29 A composition is a strong kind of aggregation —if the aggregate is destroyed, then the parts are destroyed as well Two alternatives for addresses Composition ***** RoomBuilding

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes30 Aggregation hierarchy ** * WheelTransmissionEngineFrame DoorBodyPanelChassis Vehicle

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes31 Propagation A mechanism where an operation in an aggregate is implemented by having the aggregate perform that operation on its parts At the same time, properties of the parts are often propagated back to the aggregate Propagation is to aggregation as inheritance is to generalization. —The major difference is: -inheritance is an implicit mechanism -propagation has to be programmed when required