Class Diagrams.

Slides:



Advertisements
Similar presentations
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Advertisements

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.
Class Diagram & Object Diagram
Modelling classes Drawing a Class Diagram. Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the.
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.
Object-Oriented Analysis and Design
UML Diagrams Computer Science I.
Chapter 5 – System Modeling
UML Unified Modeling Language. What is UML? Unified Modeling Language (UML) is a standardized, general-purpose modeling language in the field of software.
By: Muhammad Aamir Salem
R McFadyen Chapter 7 Conceptual Data Modeling.
1 UML Basic Training. UML Basic training2 Agenda  Definitions: requirements, design  Basics of Unified Modeling Language 1.4  SysML.
Lab 04.
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.
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.
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.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Advanced UML Class Diagrams.
An Introduction to the Unified Modeling Language
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 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.
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 3: Introducing the UML
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.
UML Fundamental Elements. Structural Elements Represent abstractions in our system. Elements that encapsulate the system's set of behaviors. Structural.
Software Modelling Class Diagram. Class Diagrams The main building block in object oriented modeling They are used both for general conceptual modeling.
Smith’s Aerospace © P. Bailey & K. Vander Linden, 2006 Classes and Objects Patrick Bailey Keith Vander Linden Calvin College.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
 Class and Diagram  Representation of Class Name Attributes Operations  Visibility of Attributes and Operations.
Entity Relationship (E-R) Model
CHAPTER
Object-Orientated Analysis, Design and Programming
Object-Oriented Modeling
UML Diagrams By Daniel Damaris Novarianto S..
Visit for more Learning Resources
Chapter 5: Structural Modeling
Course Outcomes of Object Oriented Modeling Design (17630,C604)
Inheritance Allows extension and reuse of existing code
Object-Oriented Analysis and Design
Chapter 7: Entity-Relationship Model
Outline of the ER Model By S.Saha
UML Diagrams Jung Woo.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
UML Class Diagrams: Basic Concepts
Interactions.
Object Oriented Analysis and Design
Lec 3: Object-Oriented Data Modeling
Software Engineering Lecture #11.
Module 8 – Database Design Using the E-R Model
Systems Analysis and Design With UML 2
Chapter 20 Object-Oriented Analysis and Design
CIS 375 Bruce R. Maxim UM-Dearborn
Appendix A Object-Oriented Analysis and Design
Software Engineering System Modeling Extra examples Dr.Doaa Sami
Understand and Use Object Oriented Methods
Copyright 2007 Oxford Consulting, Ltd
CIS 375 Bruce R. Maxim UM-Dearborn
Object Oriented System Design Class Diagrams
Information System Design
Appendix A Object-Oriented Analysis and Design
Chapter 6b: Database Design Using the E-R Model
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:

Class Diagrams

Object, State, Behavior, Identity Object: An object is a representation of an entity, either real-world or conceptual. State: State of an object is one of the possible conditions in which it may exist. open and closed Behavior: determines how an object responds to requests from other objects and typifies everything the object can do. add a student and delete a student

Class Diagrams The main building block in object oriented modeling They are used both for general conceptual modeling of the systematics of the application, and for detailed modeling translating the models into programming code The classes in a diagram represent both the main objects and/or interactions in the application and the objects to be programmed In the diagram these classes are represented with boxes which contain three parts

Class Diagrams In the system design of a system, a number of classes are identified and grouped together in a class diagram which helps to determine the static relations between those objects With detailed modeling, the classes of the conceptual design are often split in a number of subclasses In order to further describe the behavior of systems, these diagrams can be complemented by state diagram or UML state machine Also instead of class diagrams, Object role modeling can be used if you just want to model the classes and their relationships

Class Diagrams A class with three sections. The upper part holds the name of the class The middle part contains the attributes of the class The bottom part gives the methods or operations the class can take or undertake

The class icon Defines The class icon has Persistent system state System behavior The class icon has Name Attributes Operations It’s a rectangle divided into three compartments.

Structural Modeling: Core Elements Reference: OMG tutorial on UML by Cris Kobryn

Structural Modeling: Core Elements (cont’d) ¹ An extension mechanism useful for specifying structural elements. Reference: OMG tutorial on UML by Cris Kobryn

Structural Modeling: Core Relationships Reference: OMG tutorial on UML by Cris Kobryn

Structural Modeling: Core Relationships (cont’d) Reference: OMG tutorial on UML by Cris Kobryn

Associations An Association represents a family of links Binary associations (with two ends) are normally represented as a line, with each end connected to a class box Higher order associations can be drawn with more than two ends; in such cases, the ends are connected to a central diamond Fig. 3-40, UML Notation Guide Reference: OMG tutorial on UML by Cris Kobryn

Associations An association can be named, and the ends of an association can be adorned with role names, ownership indicators, multiplicity, visibility, and other properties There are five different types of association; bi-directional and uni-directional associations are the most common ones Fig. 3-40, UML Notation Guide Reference: OMG tutorial on UML by Cris Kobryn

Aggregations Aggregation is a variant of the "has a" or association relationship; aggregation is more specific than association It is an association that represents a part-whole or part-of relationship. As a type of association, an aggregation can be named and have the same adornments that an association can However, an aggregation may not involve more than two classes

Aggregations Aggregation can occur when a class is a collection or container of other classes, but where the contained classes do not have a strong life cycle dependency on the container—essentially, if the container is destroyed, its contents are not In UML, it is graphically represented as a hollow diamond shape on the containing class end of the tree of lines that connect contained class(es) to the containing class

Composition Fig. 3-45, UML Notation Guide Composition is a stronger variant of the "owns a" or association relationship; composition is more specific than aggregation Has a strong life cycle dependency between instances of the container class and instances of the contained class(es): If the container is destroyed, normally every instance that it contains is destroyed as well Note that a part can (where allowed) be removed from a composite before the composite is deleted, and thus not be deleted as part of the composite The UML graphical representation of a composition relationship is a filled diamond shape on the containing class end of the tree of lines that connect contained class(es) to the containing class Fig. 3-45, UML Notation Guide Reference: OMG tutorial on UML by Cris Kobryn

Generalization Indicates that one of the two related classes (the subtype) is considered to be a specialized form of the other (the super type) and supertype is considered as 'Generalization' of subtype In practice, this means that any instance of the subtype is also an instance of the supertype An exemplary tree of generalizations of this form is found in binomial nomenclature: human beings are a subtype of simian, which are a subtype of mammal, and so on. The relationship is most easily understood by the phrase 'A is a B' (a human is a mammal, a mammal is an animal). Fig. 3-47, UML Notation Guide Reference: OMG tutorial on UML by Cris Kobryn

Generalization The UML graphical representation of a Generalization is a hollow triangle shape on the supertype end of the line (or tree of lines) that connects it to one or more subtypes. The generalization relationship is also known as the inheritance or "is a" relationship. The supertype in the generalization relationship is also known as the "parent", superclass, base class, or base type. The subtype in the specialization relationship is also known as the "child", subclass, derived class, derived type, inheriting class, or inheriting type. Fig. 3-47, UML Notation Guide Reference: OMG tutorial on UML by Cris Kobryn

Generalization Note that this relationship bears no resemblance to the biological parent/child relationship: the use of these terms is extremely common, but can be misleading Generalization-Specialization relationship A is a type of B E. g. "an oak is a type of tree", "an automobile is a type of vehicle" Generalization can only be shown on class diagrams and on Use case diagrams. Fig. 3-47, UML Notation Guide Reference: OMG tutorial on UML by Cris Kobryn

Dependencies Dependency is a weaker form of relationship which indicates that one class depends on another because it uses it at some point of time It exists if a class is a parameter variable or local variable of a method of another class Fig. 3-50, UML Notation Guide Reference: OMG tutorial on UML by Cris Kobryn

UML Class Diagram Examples Reference: www.smartdraw.com

Object Diagram A diagram that shows a complete or partial view of the structure of a modeled system at a specific time Focuses on some particular set of object instances and attributes, and the links between the instances

Object Diagram A set of objects (instances of classes) and their relationships A static snapshot of a dynamic view of the system Represents real or prototypical cases Very useful before developing class diagrams Worth saving as elaborations of class diagrams

Instance Specifications Each object and link is represented by an Instance Specification This can show an object's classifier (e.g. an abstract or concrete class) and instance name, as well as attributes and other structural features using slots Each slot corresponds to a single attribute or feature, and may include a value for that entity

Instance Specifications The name on an instance specification optionally shows … an instance name, a ':' separator, and optionally one or more classifier names separated by commas The contents of slots, if any, are included below the names, in a separate attribute compartment A link is shown as a solid line, and represents an instance of an association

Example As an example, consider one possible way of modeling production of the Fibonacci sequence

Example In the first UML object diagram, the instance in the leftmost instance specification … is named v1, has IndependentVariable as its classifier, plays the NMinus2 role within the FibonacciSystem, and has a slot for the val attribute with a value of 0

Example The second object … is named v2, is of class IndependentVariable, plays the NMinus1 role, and has val = 1

Example The DependentVariable object … is named v3, and plays the N role

Example The topmost instance, an anonymous instance specification, … has FibonacciFunction as its classifier, and may have an instance name, a role, and slots, but these are not shown here

Example The diagram also includes three named links, shown as lines Links are instances of an association

Example After the first iteration, when n = 3, and f(n-2) = 1, and f(n-1) = 1, then f(n) = 1 + 1 = 2 At a slightly later point in time, the IndependentVariable and DependentVariable objects are the same, but the slots for the val attribute have different values The role names are not shown here

Example After several more iterations, when n = 7, and f(n-2) = 5, and f(n-1) = 8, then f(n) = 5 + 8 = 13 In a still later snapshot, the same three objects are involved Their slots have different values The instance and role names are not shown here

Usage If you are using a UML modeling tool, you will typically draw object diagrams using some other diagram type, such as on a class diagram An object instance may be called an instance specification or just an instance A link between instances is generally referred to as a link Other UML entities, such as an aggregation or composition symbol (a diamond) may also appear on an object diagram

More Examples Object diagram Class diagram

More Examples What does this object diagram tell us?

More Examples What would the class diagram look like that goes along with this object diagram?

More Examples Does this make sense to you?

More Examples