Class Diagrams Class diagram is basically a graphical representation of the static view of the system and represents different aspects of the application.

Slides:



Advertisements
Similar presentations
Analysis Modeling Static Modeling.
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.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
UML Class Diagram and Packages
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.
- 1 - © Houman Younessi 2010 MGMT Advanced Systems Analysis and Design A dvanced S ystems A nalysis and D esign Fall 2010 Convener: Houman Younessi.
The Unified Modeling Language
7M822 UML Class Diagrams advanced concepts 15 September 2008.
Generalizable Element Namespace Model Element name visibility isSpecification Classifier isRoot Constraint Body Coming up: Class Syntax Basic Class Diagrams.
OBJECT ORIENTED PROGRAMMING LECTURE 12 Instructor: Rashi Garg Coordinator: Gaurav Saxena.
Class Diagram.
Generalizable Element Namespace Model Element name visibility isSpecification Classifier isRoot Constraint Body Coming up: Class Syntax Basic Class Diagrams.
Generalizable Element Namespace Model Element name visibility isSpecification Classifier isRoot Constraint Body Objects, Classes, and Basic Class Diagrams.
Generalizable Element Namespace Model Element name visibility isSpecification Classifier isRoot Constraint Body Coming up: Introduction to Objects Objects,
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Databases : Data Modeling 2007, Fall Pusan National University Ki-Joune Li.
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.
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.
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.
Class Diagram Chapter 21 Applying UML and Patterns Craig Larman.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
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.
Introduction to UML Created By: Ajay Bahoriya. Acknowledgements Slides material are taken from different sources including: Slides material are taken.
Introduction to UML Mohammad Zubair Ahmad Summer 2007.
 Class and Diagram  Representation of Class Name Attributes Operations  Visibility of Attributes and Operations.
Modeling with UML – Class Diagrams
Unified Modeling Language (UML)
UML Diagrams: Class Diagrams The Static Analysis Model
COMP 2710 Software Construction Class Diagrams
Lec-4 : Unified Modeling Language (UML)
UML-Class Diagrams. UML-Class Diagrams Order placement problem A Company has two types of customers, corporate customers and personal customers. All.
A Review or Brief Introduction
Visit for more Learning Resources
Course Outcomes of Object Oriented Modeling Design (17630,C604)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Introduction to UML Shiyuan Jin Spring, 2006.
Class diagram Description
Entity-Relationship Modelling
Entity-Relationship Modeling
Today’s Objectives Define the Problem Domain
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
UML Unified Modelling Language
Software Engineering System Modeling Chapter 5 (Part 2) Dr.Doaa Sami
Software Engineering System Modeling Chapter 5 (Part 2) Dr.Doaa Sami
Introduction to UML Introduction to UML Shiyuan Jin September,23,2002
Object Oriented Analysis and Design
Seminar 3 UML Class Diagram.
Lec 3: Object-Oriented Data Modeling
Software Engineering Lecture #11.
UML Class Diagram.
Object-Oriented Knowledge Representation
Entity-Relationship Modelling
CIS 375 Bruce R. Maxim UM-Dearborn
Unified Modelling Language
Software Engineering System Modeling Extra examples Dr.Doaa Sami
Objects, Classes, and Basic Class Diagrams
Objects, Classes, and Basic Class Diagrams
ITEC 3220A Using and Designing Database Systems
Shiyuan Jin Fall, 2003 September,16,2003
Class Diagram.
CIS 375 Bruce R. Maxim UM-Dearborn
Object Oriented System Design Class Diagrams
Information System Design
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 Class diagram is basically a graphical representation of the static view of the system and represents different aspects of the application. So a collection of class diagrams represent the whole system. Each class is represented by a rectangle subdivided into three compartments Name Attributes Operations Modifiers are used to indicate visibility of attributes and operations. ‘+’ is used to denote Public visibility (everyone) ‘#’ is used to denote Protected visibility (friends and derived) ‘-’ is used to denote Private visibility (no one) By default, attributes are hidden and operations are visible. The last two compartments may be omitted to simplify the class diagrams

Class Diagrams Object Diagrams Sequence Collaboration Statechart Activity Deployment Diagrams Component Diagrams Process View Deployment View Logical View Use-Case View Implementation View End-user Functionality Programmers Software management Performance, scalability, throughput System integrators System topology, delivery, installation, communication System engineering Analysts/Designers Structure

Cont.. A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics. Graphically, a class is rendered as a rectangle, usually including its name, attributes, and operations in separate, designated compartments. Account_Name - Custom_Name - Balance +AddFunds( ) +WithDraw( ) +Transfer( ) Name Attributes Operations

Class Names The name should be a noun or noun phrase The name should be singular and description of each object in the class The name should be meaningful from a problem-domain perspective “Student” is better than “Student Data” or “S-record” or any other implementation driven name

Attributes [visibility] name [multiplicity] [:type] [=initial-value] Attributes represent characteristics or properties of classes They are place holders or slots that hold values The values they hold are other objects (or primitive types) Syntax : [visibility] name [multiplicity] [:type] [=initial-value]

Cont.. visibility: public “+”, protected “#”, or private “-” name: capitalize first letter of each word that makes up the name, except for the first multiplicity: number, range, or sequence of number or ranges. type: built-in type or any user-defined class initial-value: any constant and user-defined object A derived attribute is one that can be computed from other attributes, but doesn’t actually exist. For example, a Person’s age can be computed from his birth date. A derived attribute is designated by a preceding ‘/’ as in: / age : Date

Operation Syntax [visibility] name [(parameter-list)] [:return-type] name: verb or verb phase, capitalize first letter of every word, except first parameter-list: coma separated list of parameters return-type: primitive type or user-defined type

Operations Student Class Section major: String GPA: Real standing: String name: String capacity: Integer takes> add(Student) drop(Student) checkPrerequisites(Students) add(Class Section) drop(Class Section) <has Course Prerequisite

Type of Relationships in Class Diagrams 1.Generalization 2.Association 3.Composition 4.Aggregation 5.Realisation 6.Dependency Relation Generalization Association Dependency Binary Association N-ary Association Aggregation

Generalization relationship Indicates that objects of the specialized class (subclass) are substitutable for objects of the generalized class (super-class). “is kind of” relationship. Shape {abstract} Circle Super Class Sub Class An abstract class Generalization relationship

Generalization A sub-class inherits from its super-class Attributes Operations Relationships A sub-class may Add attributes and operations Add relationships Refine (override) inherited operation

C++ Example for Generalization class 2DPoint { int x, y; }; class 3DPpoint : 2DPoint { int z; };

is registered for> Student Semester takes> is held during> teaches> Class Section Instructor <works for is instance of> sponsors> Department Course

Class Diagram * class * * * Multiplicity: mandatory 1 Association Name class Order Multiplicity: mandatory Attributes -dateReceived -isPrepaid * Customer 1 -number :String -name -price : Money -address +dispatch() Association Operations +creditRating() : String() +close() 1 {if Order.customer.creditRating is Generalization "poor", then Order.isPrepaid must be true } Corporate Customer Personal Customer Constraint (inside braces{}} -contactName -creditCard# -creditRating Multiplicity: Many value -creditLimit +remind() +billForMonth(Integer) Multiplicity: optional 0..1 * Employee * OrderLine -quantity: Integer * 1 Product -price: Money -isSatisfied: Boolean

Associations A semantic relationship between two or more classes that specifies connections among their instances. A structural relationship, specifying that objects of one class are connected to objects of a second (possibly the same) class. Example: “An Employee works for a Company”

Associations Connect two classes Have an optional label Have multiplicities Are directional Have optional roles

Associations student 1 * University Person 0..1 * teacher employer Multiplicity Symbol Meaning 1 One and only one 0..1 Zero or one M..N From M to N (natural language) * From zero to any positive integer 0..* From zero to any positive integer 1..* From one to any positive integer Role “A given university groups many people; some act as students, others as teachers. A given student belongs to a single university; a given teacher may or may not be working for the university at a particular time.”

C++ Example Association is typically implemented with a pointer or reference instance variable. class A { private: B* b; }; A B

Cont..

Types of Association Aggregation Composition

Aggregation Used to illustrate whole-part relationship between two classes where one class is considered as whole made up of one or more classes comprising its parts. Part classes can exist without whole but when they are aggregated to a whole they are used to compromise that class. Aggregation is represented with the normal association line, but with an empty diamond at the class representing the whole

Representation Example Computer Display CPU Whole Class Part Class

Because Part classes of an aggregation association can exist on their own, this type of association implies that when the whole class is destroyed, the part classes will still exist. If the part classes are destroyed, the whole class will continue to exist. Computer CPU Display Fan Memory

Composition A form of aggregation association where the part classes used to make up the whole class cannot exist on their own. Whole class is made up of part classes and part classes need whole class to exist. Destruction of whole class means destruction of the part classes. Composition is represented with the single-line association with the addition of solid diamond at the whole class end of the line

Because association indicated that the part classes are mandatory, multiplicity of at least one is always implied for the whole class WholeClass 1 PartClass

Database Query Table Database Query Table Records 1 0..* 1..* 1 1 0..* 1..*

Object Association Relationship Patterns b) Object Aggregation Associations Whole attributes operations Class A attributes operations x x x x x x x Part1 attributes operations Part2 attributes operations PartN attributes operations x Class B attributes operations c) Object Composition Associations (y may not be “1”) Whole attributes operations Class A attributes operations x Class B attributes operations 1 1 x 1 y y y a) Object Associations Part1 attributes operations Part2 attributes operations PartN attributes operations 28