Modelling classes Drawing a Class Diagram. Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the.

Slides:



Advertisements
Similar presentations
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
Advertisements

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.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Essentials of class models. 2 A very simple class model In UML, a class is shown in a class diagram as a rectangle giving its name.
Slide 1 Systems Analysis & Design CS183 Spring Semester 2008 Dr. Jonathan Y. Clark Course Website:
Object Classes In UML. Object Concepts What is an object? How do objects communicate? How is an object’s interface defined? What have objects to do with.
Chapter 14 (Web): Object-Oriented Data Modeling
Essentials of interaction diagrams Lecture Outline Collaborations Interaction on collaboration diagrams Sequence diagrams Messages from an object.
What is UML? A modeling language standardized by the OMG (Object Management Group), and widely used in OO analysis and design A modeling language is a.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Class Diagram & Object Diagram
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Criteria for good design. aim to appreciate the proper and improper uses of inheritance and appreciate the concepts of coupling and cohesion.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
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.
PRJ566: PROJECT PLANNING AND MANAGEMENT Class Diagrams.
Chapter 14: Object-Oriented Data Modeling
1 ODB Design: Handling Associations and Inheritance in ODL M. Akhtar Ali School of Informatics.
Object-Oriented Analysis and Design
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
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.
OBJECT ORIENTED PROGRAMMING LECTURE 12 Instructor: Rashi Garg Coordinator: Gaurav Saxena.
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
OBJECT AND CLASES: THE BASIC CONCEPTS Pertemuan 8 Matakuliah: Konsep object-oriented Tahun: 2009.
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Generation and Implementation. More on classes Types Implementation classes Interfaces Templates Associations –Dependencies –Compositions.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
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.
7-1 © Prentice Hall, 2007 Chapter 7: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
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.
Unit 1 INTRODUCTION TO MODELING AND CLASS MODEL Ref : L7-UML.PDF.
© 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.
1 Class Diagrams: Advanced Concepts. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are the most commonly used diagrams.
CS212: Object Oriented Analysis and Design Lecture 13: Relationship between Classes.
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.
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.
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
Class Diagram. Classes Software Design (UML) Class Name attributes operations A class is a description of a set of objects that share the same attributes,
Class Diagram Classes are the most important building block of any object-oriented system. A class is a description of a set of objects that share the.
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.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Karolina Muszyńska Based on: S. Wrycza, B. Marcinkowski, K. Wyrzykowski „Język UML 2.0 w modelowaniu SI”
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
CMSC 345 Fall 2000 OO Design. Characteristics of OOD Objects are abstractions of real-world or system entities and manage themselves Objects are independent.
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.
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.
1 ODB Design Handling Inheritance in ODL M. Akhtar Ali School of Informatics.
Class Diagrams Revisited. Parameterized Classes Parameterized Classes - are used to represent relationships between templates.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Object-Oriented Modeling
Class Diagrams.
Entity-Relationship Model
Object Oriented Analysis and Design
Seminar 3 UML Class Diagram.
Software Engineering Lecture #11.
UML Class Diagram.
Class Diagrams Class diagram is basically a graphical representation of the static view of the system and represents different aspects of the application.
Object Oriented System Design Class Diagrams
Presentation transcript:

Modelling classes Drawing a Class Diagram

Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the attributes –Any relevant information about the class objects. Next find the operations –Any behaviour of the class – any behaviour that changes the attribute values of the class. Next find the associations –Classes are associated if they Invoke each other’s operations Have protected access to each other’s attributes.

Use Case to Class The actors are not always persistent classes The primary tasks in the use case diagram must be the responsibility of a class. Is it a persistent class? Which class holds the attributes that the operation adds / amends/ updates / deletes?

Class operations Is it public or private? –Public, if other classes use this operation –Private, if it only called by the owning class. Does it imply an association? –Yes, if other classes invoke it, or it invokes operations in other classes.

Association When the operation ‘close a claim is invoked –It invokes the ‘getage’ operation in claimant –Which invokes the operation ‘CalculateAge’ in claimant

Sub and Super Classes A super-class is an abstraction of several classes that have mostly common attributes and operations. A sub-class instance IS A super-class instance. Some super-classes have no instances themselves - they are merely abstract classes.

Generalisation A super-class is a GENERALISATION of a sub-class. A sub-class is a SPECIALISATION of a super-class. Operations and attributes in the super-class are automatically INHERITED by objects in the sub-class. Operations and attributes in the sub-class can OVERRIDE those in the super-class.

Generalisation Inheritance Information hiding Mono and polymorphism Overriding needed for –extension –restriction –convenience –Optimisation

Generalisation examples A generic ‘person’ class will have –attributes of name, address, address, phone no, etc. –Operations of Phone Mail An employee is a person A driver isan employee An assessor isan employee

And more… A radio alarm clock isa clock A watch isa clock Is a timer a clock?

General rules An object of a specialised class can be substituted for an object of a more general class in any context which expects a member of the more general class, but not the other way around. There must be no conceptual gulf between what objects of the two classes do on receipt of the same message.

Generalisations Are denoted as solid paths with a large hollow triangle pointing at the more general element. Must not be circular -i.e. an element cannot have a generalisation relationship to itself.

Sample Generalisations A School of Computing student is a student. A school of computing student is an account-holder. A lecture is a member of academic staff is a member of staff of the school of Computing. A school of computing lecturer is an account holder. A frog is a water-based animal. A frog is a land-based animal. A fish is a water-based animal. A rabbit is a land-based animal. An elephant is a land-based animal.

Specialisations More specific elements. –Specialize more general elements. –Receive all the characteristics (attributes, operations, methods and associations) of the more general elements via the mechanism of inheritance. –May add their own characteristics. –May override inherited methods. –May be substituted for their more general elements.

Starting a Class Diagram Choose your candidate objects from the system description. For each candidate: –Is there more than one object in this class? –Is this object a system user / location? –Can you describe the type of information you need to know about each member of this group of objects?

Starting Class Diagrams Rather than trying to define the entire class –concentrate on the data that is required for business classes. –set up a data model, that can be converted into a relational database, only without the keys. –later, loosen the structure, to give object- oriented advantages. –add operations on the data.

What Is an Attribute? An attribute is the type of information you need to know about each object in a class. An attribute is an attribute when:- –it has a finite length –it has a single value for each object An attribute is not an attribute when:- –it in turn has several attributes –it has multiple values

Operations The operations in a class include: –Constructor operations create new objects in the class. –Selector operations get information about and from an object in a class. –Mutator operations set information about and to an object in a class. –Destructor operations destroy objects of the class. An operation may also send a message to a class that is associated directly with the class to which the operation belongs. It can only send a message – it cannot operate on the other class!

Operations Are named services that may be requested of instances of a classifier. Are implemented by methods. May have parentheses containing a comma- separated parameter list that indicates the formal parameters passed to a method. May have a return list consisting of a comma- separated list of formal parameters passed back from a method.

Parameters –May have a kind specified. This value may be ‘in’, ‘out’ or ‘inout’. –May have a colon followed by a type expression that indicates the types of values a parameter may have. –May have an equal sign followed by a default value that is used to set the value for unspecified parameters when the method is invoked.

Return parameter Must have a name or identifier string that represents the name of the parameter. May have a colon followed by a type expression that indicates the type of values a parameter may have.

What is an association? An association is a relationship between object classes. An association is used to implement a link between objects – to send messages or instructions from one class to another. –An object from one class can invoke a method on an object from another class, thereby accessing it through its public interface.

Associations Associations correspond to verbs Express the relationship between classes –Class A and class B are associated if an object of class A Sends a message to an object of class B Creates an object of class B Has an attribute whose values are objects of class B or collections of objects of class B Receives a message with an object of class B as an argument

Multiplicity Specifies how many objects from the class are involved in each association. Each class in the association has multiplicity. It can be. –An exact number e.g. 1. –A range of numbers e.g –An arbitrary, unspecified number, using *.

Associations Associate objects from two classes. The multiplicity of the association is decided at both ends of the association. To decide on multiplicity, –Put yourself in the position of a single object from the origin class. –Ask yourself how many objects you are related to in the destination class. –This decides the multiplicity at the destination end of the association.

Types of Association Simple binary associations. –Involve two classes, where each may get information from the other. Uni-directional associations. –Involve two classes, where one can get information from the other, but not vice-versa. –E.G. Customer and order. Depending on the implementation, this could be uni- or bi- directional.

Associations May be reflexive – i.e. associate a class with itself. May have a name that represents the name of the association. May have a name-direction arrow. (Small solid triangle attached to the name, pointing in the direction of application of the name). If omitted, names are read right – left and top-bottom. May be association classes. May have an aggregation indicator.

Association Classes Are denoted as class symbols attached by dashed lines to associations. Are associations with class properties or classes with association properties. Define a set of characteristics that belong to the relationship. The characteristics are not owned by any of the classes they relate.

Aggregation Indicated by a diamond. A hollow diamond indicates weak or shared aggregation. A solid diamond indicates composition – associated class objects must belong to only one component and are deleted if the composite is deleted. Must not be associated to both ends of an association.

Multiple Class Associations Associations among three or more classes are shown as a diamond with paths from each corner / side. Such an association. –Must not involve aggregation or qualifiers. –May have a single class appear more than once or on multiple paths.

Aggregation Indicated by a diamond. A hollow diamond indicates weak or shared aggregation. A solid diamond indicates composition – associated class objects must belong to only one component and are deleted if the composite is deleted. Must not be associated to both ends of an association.