Classes and Class Diagrams. Learning Outcomes Students will be able to : Describe a class Identify components of a class diagram Explain the terms: –Multiplicity.

Slides:



Advertisements
Similar presentations
CIT731: Database Development Object Oriented Modeling (OOM)
Advertisements

Object-oriented modeling Class/Object Diagrams
7M822 UML Class Diagrams 7 October 2010.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System modeling 2.
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.
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
Slide 1 Chapter 7 Structural Modeling. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Chapter 14 (Web): Object-Oriented Data Modeling
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Class Diagram & Object Diagram
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.
7M822 UML Class Diagrams advanced concepts 14 October 2010.
Modelling classes Drawing a Class Diagram. Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the.
CET203 SOFTWARE DEVELOPMENT Session 1B Modelling and the Theory of Inheritance.
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.
Objects What are Objects Observations
Chapter 9 Domain Models. Domain Model in UML Class Diagram Notation A “visual dictionary”
ZEIT2301 Design of Information Systems Structural Design: Class Diagrams School of Engineering and Information Technology Dr Kathryn Merrick.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Part 2: Design Methodology Object-Oriented Modeling and Design
Database Management System Prepared by Dr. Ahmed El-Ragal Reviewed & Presented By Mr. Mahmoud Rafeek Alfarra College Of Science & Technology Khan younis.
CS3320::CH111 OBJECT-ORIENTED ANALYSIS Chapter 11.
Slide 1 Structural Modeling Chapter 7. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Object oriented classification Classification is the process of checking to see if an object belongs to a category or a class, is regarded as a basic attribute.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 4: Restaurant.
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.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 15: Object-Oriented Data Modeling Modern Database Management 9 h Edition Jeffrey A.
Databases : Data Modeling 2007, Fall Pusan National University Ki-Joune Li.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 13 (Online): Object-Oriented Data Modeling Modern Database Management 10 th Edition.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
Conceptual Modeling Modeling the Problem Domain. Conceptual Modeling Decompose problem space into comprehensible concepts. Clarify the terminology or.
Today in OOAD  The Domain Model Artifact UML Classes  EU-Bid Domain Model Exercise  EU-Lease Domain Model Assignment Guest Speaker  Kate Cunningham,
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 03. Classes,
Fall 2010 CS4310 Requirements Engineering A Brief Review of UML & OO Dr. Guoqiang Hu Department of Computer Science UTEP 1.
Class diagram Used for describing structure and behaviour in the use cases Provide a conceptual model of the system in terms of entities and their relationships.
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.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
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.
1 Structural Modeling Chapter 7. 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business processes.
Week III  Recap from Last Week Review Classes Review Domain Model for EU-Bid & EU-Lease Aggregation Example (Reservation) Attribute Properties.
Object-Oriented Data Modeling
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 Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Object Oriented Analysis and Design Class and Object Diagrams.
Lecture 8-2 : Class Diagrams. Class Representation Class Name Attribute1 Attribute2 … Operation1 Operation2 … responsibility.
Class Diagram Chapter 21 Applying UML and Patterns Craig Larman.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
School of Computer Science and Engineering
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi © 2013 Pearson.
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.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
CompSci 280 S Introduction to Software Development
Object-Oriented Modeling
Chapter 5: Structural Modeling
The OO Solution The OO model closely resembles the problem domain
Class diagram Description
UML Class Diagrams: Basic Concepts
Object Oriented Analysis and Design
UML Class Diagram.
Understand and Use Object Oriented Methods
Class Diagrams Class diagram is basically a graphical representation of the static view of the system and represents different aspects of the application.
Presentation transcript:

Classes and Class Diagrams

Learning Outcomes Students will be able to : Describe a class Identify components of a class diagram Explain the terms: –Multiplicity –Inheritance –Aggregation –Generalisation

What is a Class ? A description of a set of objects that share the same attributes, relationships and semantics. An abstraction 3 Parts : A Name, Attributes and Operations An object would be an instance of the class EG –Class – a libraryMember borrows a bookCopy –Object – Joe Bloggs borrows copy 1 of UML Distilled

A Class ClassName Operation1 Operation2, etc Attribute1 Attribute2, etc Window open() close() move() display() origin size Eg

Attributes Named property of a class – usually a noun Describes a range of values A class can have many attributes or none The attribute is shared by all objects of the class EG –All students have name, address, date of birth –All cats have....

Attributes... Wall height: Float width: Float thickness: Float isLoadBearing: Boolean = false Eg Can be further specified by stating their type and even a and even a default value

Operations The implementation of a service Something that can be done to an object, that is shared by all objects of that class Each class can have many operations or none Usually a verb

Operations... WashingMachine acceptClothes (c:String) acceptDetergent (d:Integer) turnOn( ) : Boolean capacity( ) : Boolean brandName: String modelName: String serialNumber: String Capacity: Integer Can be further specified by statingparameter & parameter & parametertype and function return values

Attributes and Operations with Visibility Television + changeVolume( ) + changeChannel ( ) - paintImageOnScreen ( ) + brandName: String + modelName: String Accessibility levels + Public # Protected - Private

Class responsibilities WashingMachine acceptClothes (c:String) acceptDetergent (d:Integer) turnOn( ) : Boolean capacity( ) : Boolean brandName: String modelName: String serialNumber: String Capacity: Integer In an area below The operations list you can describe the class’sresponsibility (must be done in an unambiguous way) Take dirty clothes as input and produce clean clothes as output

Class constraints WashingMachine acceptClothes (c:String) acceptDetergent (d:Integer) turnOn( ) : Boolean capacity( ) : Boolean brandName: String modelName: String serialNumber: String Capacity: Integer (capacity = 16 or 18 or 20lb)

What is a Class diagram? A description of types of objects in the system It has classes, relationships and multiplicities Constraints may be applied to the way objects are connected It may also have navigability or roles

Example Class Diagram borland.com

Associations A relationship between classes Used if there is a real-world association A short sentence – associations correspond to verbs E.g. – A player plays on a team Links can be uni-directional or bi-directional In class associations each class usually plays a role e.g. in professional team, team is employer and player is employee PlayerTeam Plays on ► EmployeeEmployer

Multiplicity Records constraints on associations Caters for permitted or required number of links (a link is an instance of an association) Specify : –An exact number (e.g. use 1) –A range of numbers (e.g. use 2..8 or 1..*) –Arbitrary, unspecified number (use *) –Discrete numbers (e.g. use 5,10)

Terms of Multiplicity OptionalOptional – lower bound of 0– lower bound of 0 MandatoryMandatory – lower bound of 1 or more– lower bound of 1 or more Single-valuedSingle-valued – upper bound of 1– upper bound of 1 MultivaluedMultivalued – upper bound of > 1 (usually *)– upper bound of > 1 (usually *)

Multiplicity Examples EggBoxEgg holds 1 12,24 CarOwner Is owned by 1..*1

Class Diagram revisited borland.com

Aggregation & Composition Ways of showing more about an association An object of one class is part of an object of another class Denoted by a diamond at the whole end of the association Composition is a special kind of aggregation – the whole owns its parts

Aggregation & Composition

Class Diagram revisited borland.com

Generalisation Uses inheritance EG – a business could have two types of customer –Corporate customer –Personal customer Both have similarities that can be placed in a general Customer class (supertype) Personal and Corporate customers are subtypes

Generalisation Example

Another Generalisation Example

Classification Relationship between an object and its type Single Classification : –Object belongs to single type –May inherit from supertypes Multiple Classification : –Object may be described by several types –Not necessarily connected by inheritance

Multiple Classification Example Agilemodeling.com

Summary - Class Model Static structure of objects in a system –Identity –Relationships –Attributes –Operations

Summary Class : Group of similar objects Association : group of similar connections between objects Generalisation : structures description of objects by organising classes by similarities/differences Attributes and Operations : elaborate structure

Domain Class Model Describes real-world classes and their relationships to each other. Information gained from :- –Problem statement –Artefacts –Expert knowledge of application domain –General knowledge of real world Does not rely on a single source

Constructing a Domain Class Model Find classes Prepare data dictionary Find associations Find attributes of objects and links Organise and simplify using inheritance Iterate and refine

Finding Classes Physical Entities –Houses, People, Machines, etc Concepts –seating assignments, payment schedules, etc Usually Nouns Extract Nouns Eliminate Spurious Classes Requirements Source Classes Tentative Classes

Eliminate Spurious Classes Is it beyond the scope of the system ? Does it refer to the system as a whole ? Does it duplicate another class ? Is it too vague ? Is it too specific ? Is it too tied up with physical I/Os ? Is it really an attribute ? Is it really an operation ? Is it really an association ?

Exercise - scenario Littlesand, Pebblesea and Mudport are three charming resorts on the south coast which are very popular with tourists, since they score well on beach ratings and hours of sunshine for the sea. All three resorts have a large number of places to stay, ranging from one-room guest houses to the exclusive Palace Hotel at Pebblesea. The local tourist board wants to set up a central system to deal with room bookings in the area. Britton & Doake (2000)

Exercise part a) & b) - Tentative Classes Write out the scenario on previous slide and underline the tentative classes (possible classes) Some of the words/phrases that you underline will class attributes Then following the example on the next slide, categorise the classes into –Vague – too vague to use –Redundant – no use for it –Implementation – concerned with implementation issues –Attribute – the item has turned out to be an attribute of a class

Exercise part b) - Bad Classes Vague Implementation Attribute Redundant

Exercise part c) - Good Classes Write out a list of the classes that you have left These will be used to create you class diagrams

Exercise part d) - Prepare Data Dictionary Isolated words can be misinterpreted Write a paragraph precisely describing each class Eg: Room – a room at a place to stay against which bookings can be made. Rooms may be of various types. A place to stay can contain more than one room.

Exercise part e) - Initial Class Diagram - construct a class diagram showing just class names

Exercise part f) - Find Associations and multiplicity Show relationships between classes Often correspond verbs : –Physical Locations (NextTo, PartOf, ContainedIn, etc –Directed actions (Drives) –Communication (TalksTo) –Ownership (Has, PartOf) –Satisfaction of Condition (WorksFor, MarriedTo, Manages, etc)

Exercise part g) - Find Attributes for the main (resort) class Data Properties of individual objects Use –Knowledge of application domain –Artefacts Capture the most important – you can add detail later

Exercise part h) - Refine Using Inheritance Bottom-up generalisation –Classes with similar attributes, associations, operations –Define superclass to share common features Top-down specialisation –Similar class names (eg fixed menu, pop-up menu, sliding menu)

Further Reading Object-Oriented Modelling and Design with UML, Michael Blaha and James Rumbaugh, UML Distilled, Martin Fowler,Addison Wesley ISBN Using UML, Perdita Stevens Object-Oriented System Development (2000) Britton & Doake