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.

Slides:



Advertisements
Similar presentations
UML (cont.) “The Unified Modeling Language User Guide” by G. Booch, J. Rumbaugh and I. Jacobson ● Classes ● Relationships ● Class diagrams ● Examples.
Advertisements

CIT731: Database Development Object Oriented Modeling (OOM)
Object-oriented modeling Class/Object Diagrams
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 Diagrams.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS6th Edition.
Class Diagram & Object Diagram
7M822 UML Class Diagrams advanced concepts 15 September 2008.
Classes Chapter 4. Terms and Concepts A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics.
Modelling classes Drawing a Class Diagram. Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation (Adapted) Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra,
1 Object-Oriented Modeling Using UML CS 3331 Fall 2009.
PRJ566: PROJECT PLANNING AND MANAGEMENT Class Diagrams.
Object-Oriented Analysis and Design
UML Diagrams Computer Science I.
ECE 355: Software Engineering
Unified Modeling Language User Guide Section 2—Basic Structural Modeling Chapter 4—Classes.
OBJECT ORIENTED PROGRAMMING LECTURE 12 Instructor: Rashi Garg Coordinator: Gaurav Saxena.
Lawrence ChungCS6359.0T1: Module 41 Module 4: Relationships.
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.
UML Diagrams: Class Diagrams The Static Analysis Model Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
R McFadyen Chapter 7 Conceptual Data Modeling.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
7-1 © Prentice Hall, 2004 Chapter 7: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
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.
7-1 © Prentice Hall, 2007 Week 5: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Databases : Data Modeling 2007, Fall Pusan National University Ki-Joune Li.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
® 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.
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.
An Introduction to the Unified Modeling Language
What is a Structural Model?
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.
2007ACS-3913 Ron McFadyen1 Class Diagram See Schaum’s UML Outline, especially chapters 4, 5, 6, 7.
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,
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.
Class Modeling Design Class diagram. Classes The term “class ” refers to a group of objects that share a common attributes and common behaviour (operations).
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Ch- 8. Class Diagrams Class diagrams are the most common diagram found in modeling object- oriented systems. Class diagrams are important not only for.
Class Diagram Chapter 21 Applying UML and Patterns Craig Larman.
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.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
UML Part 1: Class Diagrams. Introduction UML stands for Unified Modeling Language. It represents a unification of the concepts and notations presented.
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
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.
Unified Modeling Language (UML)
UML Diagrams: Class Diagrams The Static Analysis Model
Visit for more Learning Resources
Chapter 5: Structural Modeling
Course Outcomes of Object Oriented Modeling Design (17630,C604)
Class Diagrams.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Introduction to Unified Modeling Language (UML)
Object Oriented Analysis and Design
UML Class Diagram.
Unified Modelling Language
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:

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 same attributes, operations, relationships, and semantics. A class implements one or more interfaces. Class diagrams are the most common diagram found in modeling object- oriented systems. A class diagram shows a set of classes, interfaces, and collaborations and their relationships. A class is not an individual object, but rather represents a whole set of objects. Thus, you may conceptually think of "wall" as a class of objects with certain common properties, such as height, length, thickness. The UML provides a graphical representation of class. Graphically a class is rendered as a rectangle.

Class Diagram contd… A class is rendered as a rectangle, distributed in three compartments. The first compartment holds the Class name, second holds Attributes and third holds Operations. Names A class name must be unique within its enclosing package. Every class must have a name that distinguishes it from other classes. A name is a textual string. That name alone is known as a simple name; a path name is the class name prefixed by the name of the package in which that class lives.

Attributes An attribute is a named property of a class that describes a range of values that instances of the property may hold. A class may have any number of attributes or no attributes at all. An attribute represents some property of the thing you are modeling that is shared by all objects of that class. For example, every wall has a height, width, and thickness; you might model your customers in such a way that each has a name, address, phone number, and date of birth.

Names An attribute name may be text, just like a class name. In practice, an attribute name is a short noun or noun phrase that represents some property of its enclosing class. Typically, you capitalize the first letter of every word in an attribute name except the first letter, as in name or loadBearing. You can further specify an attribute by stating its class and possibly a default initial value,

Attribute Containment types It describes how an attribute store within a class. By value Attribute stores within in the class. By reference Attribute stores outside the class. Unspecified Containment is not yet specified. by default Rose assume by value. Static A static attribute has only one instance of a class. A $ sign is used to show it. Derived Attribute A derived attribute is created from one or more other attributes. area = width * height. A / sign is used to show a derived attribute.

Operations An operation is the implementation of a service that can be requested from any object of the class to affect behavior. In other words, an operation is an abstraction of something you can do to an object and that is shared by all Objects of that class. A class may have any number of operations or no operations at all. Names An operation name may be text, just like a class name. In practice, an operation Name is a short verb or verb phrase that represents some behavior of its enclosing class. Typically, you capitalize the first letter of every word in an operation name except the first letter, as in move or isEmpty.

You can specify an operation by stating its signature, covering the name, type, and default value of all parameters and a return type.

Organizing Attributes and Operations When drawing a class, you don't have to show every attribute and every operation at once. To better organize long lists of attributes and operations, you can also prefix each group with a descriptive category by using stereotypes.

Types of Operations Implementor Operations implements some business functionality. They can be found by examining Interaction diagram. Manager Operations Manage the creation and destruction of objects. Access Operations Set and get operation in a class to access private attributes. Helper Operations Help other operation of the class, but cant be access directly. Private operation of a class.

Responsibilities A responsibility is a contract or an obligation of a class. When you create a class, you are making a statement that all objects of that class have the same kind of state and the same kind of behavior. At a more abstract level, these corresponding attributes and operations are just the features by which the class's responsibilities are carried out.

Responsibilities Responsibilities can be drawn in a separate compartment at the bottom of the class. A class can have more then one responsibilities, every well structured class has at least one responsibility. Shape origin... move() resize() display()... Responsibilities... shows that there are more operation or attributes in this class

Stereotypes The UML provides a language for structural things, behavioral things, grouping things, and notational things. These four basic kinds of things address the overwhelming majority of the systems you'll need to model. However, sometimes you'll want to introduce new things that speak the vocabulary of your domain and look like primitive building blocks. A stereotype is an extension of the vocabulary of the UML, allowing you to create new kinds of building blocks similar to existing ones but specific to your problem. Graphically, a stereotype is rendered as a name enclosed by > and placed above the name of another element. Stereo typing is a way to categorize some thing in your diagram. Stereotype are the core extension mechanism of UML

Class stereotypes in UML There are three class stereotypes in UML Boundary Classes Control Classes Entity Classes

Boundary Classes Are those classes which lies between your system and real world, such as form, reports and hardware interfaces printers and scanners. To find boundary classes check the use cases, you will find at a minimum one boundary class for every actor interacting with the system. Two actors can have same one boundary class. Entity Classes These classes saves the information in persistent storage. You can create tables in your database for each entity class. Control Classes The control class is responsible for coordinating the efforts of other classes. Typically there is only one control class per use case. Control class delegates responsibility to other classes. There may be other control classes that share between several use cases. e.g. Security manager for controlling security. Transaction manager class for Database transaction. Minimize the impact of changes on system

Visibility One of the most important details you can specify for a classifier's attributes and operations is its visibility. The visibility of a feature specifies whether it can be used by other classifiers. In the UML, you can specify any of three levels of visibility. public Any outside classifier with visibility to the given classifier can use the feature; specified by prepending the symbol + protected Any descendant of the classifier can use the feature; specified by prepending the symbol # private Only the classifier itself can use the feature; specified by prepending the symbol – No sign represents a package visibility.

Multiplicity Whenever you use a class, it's reasonable to assume that there may be any number of instances of that class (unless, of course, it is an abstract class and so it may not have any direct instances, although there may be any number of instances of its concrete children). Sometimes, though, you'll want to restrict the number of instances a class may have. Most often, you'll want to specify zero instances (in which case, the class is a utility class that exposes only class scoped attributes and operations), one instance (a singleton class), a specific number of instances, or many instances (the default case). The number of instances a class may have is called its multiplicity. Is an indication of how many objects may participate in a given relationship.

Setting Class multiplicity – n (default) many – 0..0 Zero – 0..1 Zero or One – 0..n Zero or many – 1..1 Only One – 1..n One or many – Exactly –.. Between and –..n or more –, or –,.. Exactly or between and..,.. Between and or between and

Setting Class Persistence Persistent The information in objects of the class will be saved to a database or some other form of persistent storage. Transient The information in objects will not be saved to persistent storage

Relationships When you build abstractions, you'll discover that very few of your classes stand alone. Instead, most of them collaborate with others in a number of ways. Therefore, when you model a system, not only must you identify the things that form the vocabulary of your system, you must also model how these things stand in relation to one another. A relationship is a connection among things. Three types of relationships : 1. Association 2.Dependency 3.Generalization Association represent structural relationships among objects. Dependency represent using relationships. Generalization represent link between generalized classes to their specializations.

Association An association is a structural relationship that specifies that object of one thing are connected to objects of another. You can navigate from an object of one class to an object of the another class. Objects of one class can link to other objects of same class. An association that connects exactly two classes is called a binary association. An association that connects more than two classes is called n-ary association. An association is rendered as a solid line connecting the same or different classes. Associations are represented by attributes in a class.

Association properties Name An association can have a name. That describe the nature of the relationship. Role A role is just the face the class at the near end of the association present to the class at the other end of the association. Multiplicity It represent that how many objects of one class may connect to the objects of another class. Navigation It represent the direction of association from one object to another object. Unless specified the navigation is bi-directional. You can limit the navigation to just one direction.

Works for Name PersonCompany employee PersonCompany employer Role name employee PersonCompany employer 1..* * Person Parent Child * 2

Aggregation Aggregation is a relationship between a whole and its part. Aggregation is a type of association. In aggregation one class represent a larger thing (the whole) which consist of smaller thing (the parts). Aggregation represent a “has a” relationship. Company Department Whole Part 1 *

Composition Composition is a variation of aggregation. In composition one class represent a larger thing (the whole) which consist of smaller thing (the parts). Parts may be created after the whole, but once created they live and die with the whole. Window Frame Whole Part 1 * It is represented by a Filled diamond.

Dependency An dependency is a using relationship, states that a change in the specification of one thing may affect another thing that uses it. A dependency can have a name. Dependency is rendered as a dashed directed line, directed to the thing being dependent on. Dependency cannot be represented by a class attribute. It can be represented by global class, or instantiated as a local variable inside an operation or passed as a parameter to some operation.

Generalization An generalization is a relationship between general thing (called the super or parent) and a more special kind of that thing (called the subclass or child). Generalization represents “is-a” or “is-a-kind-of “ relationship. A child inherits the properties of its parents, especially their attributes and operations. An operation of a child that has the same signature as an operation in a parent overrides the operation of the parent, this is known as polymorphism. A class can have zero, one or more parents. A class that has no parents and one or more children is called a root or base class. A class that has one parent is said to use single inheritance, with more then one parents is said to use multiple inheritance. Generalization is rendered as a solid directed line with a large open arrow head.

Company Department ContractInformation Headquarters PersonnelRecord Office name Person name employeeID title getName getID getContractInformation getPersonnelRecords taxID emplomentHistory salary address phone address 1..* *1 manager member 1 * Location ** dependency role generalization aggregation multiplicity attributes operations class

Student name studentID School -name -address -phone +addStudent() +removeStudent() +getStudent() +getAllStudent() +addDepartment() +getDepartment() +getAllDepartment() Department -name +addIntructor() +removeInstructor() +getInstructor() +getAllInstructor() Course name courseID Instructor name Has AssignedTo Member Attends Teaches * * 1 * * * * role:chairperson