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.

Slides:



Advertisements
Similar presentations
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.
Advertisements

UML Class and Sequence Diagrams Violet Slides adapted from Marty Stepp, CSE 403, Winter 2012 CSE 403 Spring 2012 Anton Osobov.
UML – Class Diagrams.
Chapter 14 (Web): Object-Oriented Data Modeling
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 
© Copyright Eliyahu Brutman Programming Techniques Course.
7M822 UML Class Diagrams advanced concepts 15 September 2008.
7M822 UML Class Diagrams advanced concepts 14 October 2010.
Chapter 14: Object-Oriented Data Modeling
1 TCSS 360, Spring 2005 Lecture Notes Design Phase and UML Class Diagrams Relevant Reading: UML Distilled, Third Edition M. Fowler.
Unified Modeling Language
The Unified Modeling Language (UML) Class Diagrams.
Object-Oriented Analysis and Design
OO Analysis and Design CMPS OOA/OOD Cursory explanation of OOP emphasizes ▫ Syntax  classes, inheritance, message passing, virtual, static Most.
Lawrence ChungCS6359.0T1: Module 41 Module 4: Relationships.
Software Construction Lecture 5 Class Diagrams. Agenda 2  Topics:  Examples of class diagrams  Navigation, visibility, named associations, and multiplicity.
CIT UPES | Sept 2013 | Unified Modeling Language - UML.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part V: Design The Design Workflow Design Classes Refining Analysis Relationships.
UML Diagrams: Class Diagrams The Static Analysis Model Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
1 UML Basic Training. UML Basic training2 Agenda  Definitions: requirements, design  Basics of Unified Modeling Language 1.4  SysML.
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.
1 © Prentice Hall, 2002 Chapter 14: Object-Oriented Data Modeling Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 15 System Modeling with the UML.
© 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.
Chapter 16 Applying UML and Patterns Craig Larman
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 03. Classes,
1 Class Diagrams: The Essentials. 2 Terms and Concepts A class is... The most important building block of any object-oriented system. A description of.
UML Diagrams: The Static Model Class Diagrams. The Static Model Define the static structure of the logical model Represent classes, class hierarchies.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Advanced UML Class Diagrams.
UML Class Diagrams 1 These lecture slides are copyright (C) Marty Stepp, They may not be rehosted, sold, or modified without expressed permission.
Fundamentals of Computer Science The Object-Oriented Paradigm and UML.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Design Jon Walker. More UML ● What is UML again?
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis and Design Class and Object Diagrams.
1 Class Diagrams. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are for visualizing, specifying and documenting.
12 OBJECT-ORIENTED DESIGN CHAPTER
Chapter 3 Class Diagrams. 2 Outline Class Basics Class Basics Classes Classes Association Association Multiplicity Multiplicity Inheritance Inheritance.
1 Introduction to Classes. 2 Terms and Concepts A class is... –The most important building block of any object- oriented system. –A description of a set.
Modeling the Static Structure: Relationships ©SoftMoore ConsultingSlide 1.
UML Part 1: Class Diagrams. Introduction UML stands for Unified Modeling Language. It represents a unification of the concepts and notations presented.
Class diagrams Terézia Mézešová.
Chapter 16: UML Class Diagrams
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Chapter 5 System Modeling. What is System modeling? System modeling is the process of developing abstract models of a system, with each model presenting.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi © 2013 Pearson.
UML Fundamental Elements. Structural Elements Represent abstractions in our system. Elements that encapsulate the system's set of behaviors. Structural.
WELCOME TO OUR PRESENTATION UNIFIED MODELING LANGUAGE (UML)
Introduction to Unified Modeling Language (UML) By Rick Mercer with help from The Unified Modeling Language User Guide, Grady Booch, James Rumbaugh, Ivar.
Software Modelling Class Diagram. Class Diagrams The main building block in object oriented modeling They are used both for general conceptual modeling.
COP 3330 Notes 4/13. Today’s Topics UML Class Diagrams.
TCSS 305 (Stepp) OO Design with UML Class Diagrams
Object-Orientated Analysis, Design and Programming
Unified Modeling Language
Lecture on Design Phase and UML Class Diagrams
Reference: COS240 Syllabus
UML Diagrams: The Static Model Class Diagrams
Object Oriented Analysis and Design
Software Engineering Lecture #11.
Packages and Interfaces
Multiple Inheritance & Interfaces
Class Diagrams.
Business Analysis More on Classes Chris Russell O2.41
Object Oriented System Design Class Diagrams
UML  UML stands for Unified Modeling Language. It is a standard which is mainly used for creating object- oriented, meaningful documentation models for.
Presentation transcript:

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 in UML. Class diagrams are for visualizing, specifying and documenting the system from a static perspective. Class diagrams are for visualizing, specifying and documenting the system from a static perspective. Class diagrams indicate which classes know about other classes and, if they do, what type of relationship exists. Class diagrams indicate which classes know about other classes and, if they do, what type of relationship exists. Class diagrams will have different levels of detail (abstraction) depending on where we are in the software development process. Class diagrams will have different levels of detail (abstraction) depending on where we are in the software development process.

3 Overview

4 Static Operations and Attributes Scope Scope Individual member data (attributes) may have either class scope or instance scope. Individual member data (attributes) may have either class scope or instance scope. Class scope - A single copy of an attribute is shared by all instances of a class. Class scope - A single copy of an attribute is shared by all instances of a class. In UML you underline the attribute to indicate class scope: productCount : int In UML you underline the attribute to indicate class scope: productCount : int In C++ and Java members with class scope would be declared as static: static int productCount In C++ and Java members with class scope would be declared as static: static int productCount Instance scope - Each instance of a class would have its own copy of the attribute. All attributes have instance scope by default. Instance scope - Each instance of a class would have its own copy of the attribute. All attributes have instance scope by default.

5 Static Operations and Attributes Static attributes have class scope Static features are underlined on a class diagram Italicized class name means abstract class.

6 Aggregate and Composition Aggregation is … Aggregation is … A relationship between two classes. A relationship between two classes. A form of association. A form of association. Used to show a ‘has-a’ or a ‘whole-part’ relationship. Used to show a ‘has-a’ or a ‘whole-part’ relationship. Graphically represented as a solid line with an open diamond on the ‘whole’ end. Graphically represented as a solid line with an open diamond on the ‘whole’ end. Aggregations and associations are implemented in exactly the same way. The difference is entirely conceptual. Aggregations and associations are implemented in exactly the same way. The difference is entirely conceptual.

7 Aggregate and Composition Composition is … Composition is … A relationship between two classes. A relationship between two classes. Used to show a ‘contains-a’ or a ‘whole-part’ relationship. Used to show a ‘contains-a’ or a ‘whole-part’ relationship. Graphically represented as a solid line with a solid diamond on the ‘whole’ end. Graphically represented as a solid line with a solid diamond on the ‘whole’ end. Composition relationships and associations are not implemented in exactly the same way. Composition relationships and associations are not implemented in exactly the same way. If the ‘whole’ object is destroyed, the part object will also be destroyed. If the ‘whole’ object is destroyed, the part object will also be destroyed.

8 Aggregate and Composition Composition is … Composition is … A relationship between two classes. A relationship between two classes. Used to show a ‘contains-a’ or a ‘whole-part’ relationship. Used to show a ‘contains-a’ or a ‘whole-part’ relationship. Graphically represented as a solid line with a solid diamond on the ‘whole’ end. Graphically represented as a solid line with a solid diamond on the ‘whole’ end. Composition relationships and associations are not implemented in exactly the same way. Composition relationships and associations are not implemented in exactly the same way. If the ‘whole’ object is destroyed, the part object will also be destroyed. If the ‘whole’ object is destroyed, the part object will also be destroyed.

9 Aggregate and Composition

10 Aggregate and Composition

11 Common Modeling Technique Modeling dependency, association, aggregation and composition relationships. Modeling dependency, association, aggregation and composition relationships. It is not always easy to determine which is the best relationship to use. It all has to do with your perspective of the problem domain. It is not always easy to determine which is the best relationship to use. It all has to do with your perspective of the problem domain. There is not always one best solution. There is not always one best solution. Personal experience is your most valuable modeling tool. Personal experience is your most valuable modeling tool. CRC cards are helpful. CRC cards are helpful.

12 Common Modeling Technique Multiple class diagrams are required to model large systems. Multiple class diagrams are required to model large systems. Each individual class diagram … Each individual class diagram … Shows a single aspect of the system. Shows a single aspect of the system. Contains only elements that are essential to understanding that aspect. Contains only elements that are essential to understanding that aspect. Provide details consistent with its level of abstraction. Provide details consistent with its level of abstraction. Uses meaningful class and member names. Uses meaningful class and member names. Pointers to other classes are modeled as associations. Pointers to other classes are modeled as associations.

13 Common Modeling Technique A well-defined class is loosely coupled (few entry points) and highly cohesive (all members work toward a common functionality). A well-defined class is loosely coupled (few entry points) and highly cohesive (all members work toward a common functionality). Ask yourself “Am I trying to show what the class does or how it does it”. That will tell you at what level of abstraction to model the class. Ask yourself “Am I trying to show what the class does or how it does it”. That will tell you at what level of abstraction to model the class. In the requirements and specification phase you are interested in “what”. In the design phase you are interested in “how”. In the requirements and specification phase you are interested in “what”. In the design phase you are interested in “how”. Don’t hesitate to attach notes to the class icons if further clarification is necessary. Don’t hesitate to attach notes to the class icons if further clarification is necessary.

14 Interfaces and Abstract Classes Abstract Class Abstract Class A abstract class cannot have any direct instances. A abstract class cannot have any direct instances. Not all OO programming languages directly support abstract classes. (In C++ abstract classes contain one or more pure virtual functions). Not all OO programming languages directly support abstract classes. (In C++ abstract classes contain one or more pure virtual functions). int myFunction(int x) = 0; int myFunction(int x) = 0; Pure virtual functions have no function body. Pure virtual functions have no function body. An abstract class is thought to be so general as to be useless by itself. An abstract class is thought to be so general as to be useless by itself. Abstract classes only occur in the context of an inheritance hierarchy. Abstract classes only occur in the context of an inheritance hierarchy. In UML you specify that a class is abstract by writing its name in italics. In UML you specify that a class is abstract by writing its name in italics.

15 Interfaces and Abstract Classes An interface is a class that has no implementation. All of its features are abstract Corresponds directly to interfaces in Java

16 Association Class An association class… An association class… is used to model an association as a class. is used to model an association as a class. is rendered by a dashed line from the association to the class rectangle. is rendered by a dashed line from the association to the class rectangle. is essentially a class attached to an association; the association itself is modeled as a class. is essentially a class attached to an association; the association itself is modeled as a class. Each link in the association is an object of the association class. Each link in the association is an object of the association class. A link is an instance of an association A link is an instance of an association a link is to an association as an object is to a class a link is to an association as an object is to a class

17 Association Class Things to consider: Things to consider: You can’t attach the same class to more than one association; an association class is the association. You can’t attach the same class to more than one association; an association class is the association. The name of the association is usually omitted since it is considered to be the same as that of the attached class. The name of the association is usually omitted since it is considered to be the same as that of the attached class. Distinguish between the use of an association class as a modeling technique and the implementation of the association class. There can be several ways to implement an association class. Distinguish between the use of an association class as a modeling technique and the implementation of the association class. There can be several ways to implement an association class.

18 Association Class

19 Association Class

20 Association Class

21 Visibility Visibility Visibility Class members (attributes and behaviors) may be specified as public (+), private (-), or protected (#). Class members (attributes and behaviors) may be specified as public (+), private (-), or protected (#). In UML the single character visibility indicator is placed to the left of the member. In UML the single character visibility indicator is placed to the left of the member. # myProtectedFunction( ) # myProtectedFunction( ) - myPrivateFunction( ) - myPrivateFunction( ) + myPublicFunction( ) + myPublicFunction( ) Restricting visibility is the same as restricting accessibility. By restring accessibility you are limiting the number of entry points into an object. By restricting the number of entry points you are facilitating debugging and code re- use. Restricting visibility is the same as restricting accessibility. By restring accessibility you are limiting the number of entry points into an object. By restricting the number of entry points you are facilitating debugging and code re- use.