SlideShare ist ein Scribd-Unternehmen logo
1 von 44
OOAD
Class
Diagram
What is a Class Diagram?
• A Class Diagram is a diagram describing
the structure of a system
• shows the system's
• classes
• Attributes
• Operations (or methods),
• Relationships among the classes.
What is a Class Diagram?
• A class diagram depicts classes and their
interrelationships
• Used for describing structure and behavior in the
use cases
• Provide a conceptual model of the system in
terms of entities and their relationships
• Used for requirement capture, end-user
interaction
• Detailed class diagrams are used for developers
Essential Elements of a UML Class Diagram
• Class
• Attributes
• Operations
• Relationships
– Associations
– Generalization
– Realization
– Dependency
• Constraint Rules and Notes
Class
• Describes a set of objects having
similar:
– Attributes (status)
– Operations (behavior)
– Relationships with other classes
• Graphically, a class is rendered as
a rectangle, usually including its
name, attributes, and operations
in separate, designated
compartments.
Class Names
The name of the class is the only
required tag in the graphical
representation of a class. It always
appears in the top-most
compartment.
Class
Class Attributes and Operations
An attribute is a named property of a class that describes the object
being modeled.
In the class diagram, attributes appear in the second compartment
just below the name-compartment.
Attributes can be:
+ public
# protected
- private
Attributes are usually listed in the form:
attributeName : Type
Operations describe the class behavior and appear in the third
compartment.
Visibility and Access for attributes
and operations of a class
Class
Account_Name
- Customer_Name
- Balance
+addFunds( )
+withDraw( )
+transfer( )
Name
Attributes
Operations
Class Attributes and Operations
Class Attributes:
 The attribute type is shown after
the colon.
 Attributes map onto member
variables (data members) in code.
Class Operations (Methods):
 The return type of a method is
shown after the colon at the end of
the method signature.
 The type of method parameters
are shown after the colon following
the parameter name.
 Operations map onto class
methods in code
Operation (Method) Parameter Directionality
Parameter
direction
Description
in states that p1 and p2 are passed to
op1 by the caller.
They are both in parameters.
inout states that p3 is passed to op2 by
the caller and is then possibly
modified by op2 and is passed back
out.
p3 is an inout parameter.
out states that p6 is not set by the caller
but is modified by op3 and is passed
back out.
p6 is an out parameter.
Association
• In UML, object interconnections (logical or
physical), are modeled as relationships.
• An association between two classes indicates
that objects at one end of an association
“recognize” objects at the other end and may
send messages to them.
• Example: “An Employee works for a
Company”
Employee Company
Association Relationships
If two classes in a model need to communicate with
each other, there must be link between them.
An association denotes that link.
InstructorStudent
Association Relationships
We can indicate the multiplicity of an association by
adding multiplicity adornments to the line denoting
the association.
The example indicates that a Student has one or more
Instructors:
InstructorStudent
1..*
Association Relationships
The example indicates that every Instructor has one or
more Students:
InstructorStudent
1..*
Association Relationships
We can also indicate the behavior of an object in an
association (i.e., the role of an object) using
rolenames.
InstructorStudent
1..*1..*
learns fromteaches
Association Relationships
We can also name the association.
TeamStudent
membership
1..* 1..*
Association Relationships
We can specify dual associations.
TeamStudent
member of
1..*
president of1 1..*
1..*
Associations
• Multiplicity
– the number of objects that participate in the association.
– Indicates whether or not an association is mandatory.
Exactly one 1
Zero or more (unlimited) * (0..*)
One or more 1..*
Zero or one (optional association) 0..1
Specified range 2..4
Multiple, disjoint ranges 2, 4..6, 8
Multiplicity Indicators
Association Relationships
A class can have a self association.
LinkedListNode
next
previous
Aggregation
• A special form of association that models a
whole-part relationship between an aggregate
(the whole) and its parts.
• A directional association between objects.
• When an object ‘has-a’ another object, then
you have got an aggregation between them.
• Direction between them specified which
object contains the other object.
• It is also called ‘Has-a’ relationship.
Aggregation
 Class2 is part of Class1.
 Many instances (denoted by the *) of Class2
can be associated with Class1.
 Objects of Class1 and Class2 have separate
lifetimes.
Aggregation
• Note: If you delete the parent object, even
then the child object may exist. One object
can contain the other, but there is no
restriction that the composed object has to
exist in order to have existence of child object.
Aggregation
Whole Part
Car Door
2..*
Composition
• A strong form of aggregation
• In a more specific manner, a restricted
aggregation is called composition.
– The whole is the sole owner of its part.
• The part object may belong to only one whole
– The life time of the part is dependent upon the
whole.
• The composite must manage the creation and
destruction of its parts.
Composition
 Objects of Class2 live and die with
Class1.
 Class2 cannot stand by itself.
Composition
• A class contains students. A student cannot
exist without a class. There exists composition
between class and students.
Difference between aggregation
and composition
• Composition is more restrictive.
• When there is a composition between two objects,
the composed object cannot exist without the other
object.
• This restriction is not there in aggregation. Though
one object can contain the other object, there is no
condition that the composed object must exist.
• The existence of the composed object in aggregation
is entirely optional.
Difference between aggregation
and composition
• Example: A Library contains students and books.
Relationship between library and student is
aggregation.
• Relationship between library and book is
composition.
– A student can exist without a library and therefore it is
aggregation.
– A book cannot exist without a library and therefore its a
composition.
Generalization Relationship
o A generalization connects a
subclass to its superclass. It denotes
an inheritance of attributes and
behavior from the superclass to the
subclass and indicates a
specialization in the subclass of the
more general superclass.
o “is kind of” relationship.
Subtype2Subtype1
Supertype
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 operations
Person
Student
Generalization Relationships
UML permits a class to inherit from multiple superclasses,
although some programming languages (e.g., Java) do not
permit multiple inheritance.
Student
TeachingAssistant
Employee
Generalization Relationships
 Inheritance is indicated by a solid line with a closed, 
unfilled arrowhead pointing at the super class
Generalization Relationships
An example of inheritance using tree notation
Packages
 UML provides an organizing element called
a package.
 Packages enable modelers to organize the
model's classifiers into namespaces, which is sort
of like folders in a filing system.
 Dividing a system into multiple packages
makes the system easier to understand,
especially if each package represents a specific
part of the system.
Drawing Packages
• There are two ways of drawing packages on
diagrams.
1. If the modeler decides to show the package's
members within the large rectangle, then all
those members need to be placed within the
rectangle.
Packages
Drawing Packages
2. If the modeler decides to show the package's
members outside the large rectangle then all
the members that will be shown on the
diagram need to be placed outside the
rectangle. To show what classifiers belong to
the package, a line is drawn from each
classifier to a circle that has a plus sign inside
the circle attached to the package
Packages
Realization
• A realization relationship indicates that one
class implements a behavior specified by
another class (an interface or protocol).
• An interface can be realized by many
classes.
• A class may realize many interfaces.
LinkedList
<<interface>>
List ArrayList
Constraint Rules and Notes
• Constraints and notes annotate among other things
associations, attributes, operations and classes.
• Constraints are semantic restrictions noted as
Boolean expressions.
– UML offers many pre-defined constraints.
id: long { value > 0 }
Customer
Order
*1
{ total < $50 }
may be
canceled
Constraint Note
What is a Object Diagram?
• Object diagrams represent an instance of a
class diagram.
• The purposes of object diagrams are similar to
class diagrams.
• The difference is that a class diagram
represents an abstract model consisting of
classes and their relationships. But an object
diagram represents an instance at a particular
moment which is concrete in nature.
Class and Objects

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
 
Class diagram
Class diagramClass diagram
Class diagram
 
Uml Presentation
Uml PresentationUml Presentation
Uml Presentation
 
Association agggregation and composition
Association agggregation and compositionAssociation agggregation and composition
Association agggregation and composition
 
Sequence diagram- UML diagram
Sequence diagram- UML diagramSequence diagram- UML diagram
Sequence diagram- UML diagram
 
SE_Lec 07_UML CLASS DIAGRAM
SE_Lec 07_UML CLASS DIAGRAMSE_Lec 07_UML CLASS DIAGRAM
SE_Lec 07_UML CLASS DIAGRAM
 
Ooad
OoadOoad
Ooad
 
Uml - An Overview
Uml - An OverviewUml - An Overview
Uml - An Overview
 
Activity diagram
Activity diagramActivity diagram
Activity diagram
 
Activity diagram-UML diagram
Activity diagram-UML diagramActivity diagram-UML diagram
Activity diagram-UML diagram
 
CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3
 
Object oriented methodologies
Object oriented methodologiesObject oriented methodologies
Object oriented methodologies
 
Object diagram
Object diagramObject diagram
Object diagram
 
Lecture#08 sequence diagrams
Lecture#08 sequence diagramsLecture#08 sequence diagrams
Lecture#08 sequence diagrams
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Sequence Diagram
Sequence DiagramSequence Diagram
Sequence Diagram
 
state modeling In UML
state modeling In UMLstate modeling In UML
state modeling In UML
 
UML Diagram @ Software engineering discussion
UML Diagram @ Software engineering discussionUML Diagram @ Software engineering discussion
UML Diagram @ Software engineering discussion
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
 
UML
UMLUML
UML
 

Andere mochten auch

Lecture-03 Introduction to UML
Lecture-03 Introduction to UMLLecture-03 Introduction to UML
Lecture-03 Introduction to UMLartgreen
 
Uml diagrams
Uml diagramsUml diagrams
Uml diagramsbarney92
 
Structured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and DesignStructured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and DesignMotaz Saad
 
4.class diagramsusinguml
4.class diagramsusinguml4.class diagramsusinguml
4.class diagramsusingumlAPU
 
UML basic - Class Diagram
UML basic - Class DiagramUML basic - Class Diagram
UML basic - Class DiagramYeti Sno
 
Class diagram- UML diagram
Class diagram- UML diagramClass diagram- UML diagram
Class diagram- UML diagramRamakant Soni
 
Object Modelling in Software Engineering
Object Modelling in Software EngineeringObject Modelling in Software Engineering
Object Modelling in Software Engineeringguest7fe55d5e
 
Unified Modelling Language
Unified Modelling LanguageUnified Modelling Language
Unified Modelling LanguageR A Akerkar
 
01 introduction to entity framework
01   introduction to entity framework01   introduction to entity framework
01 introduction to entity frameworkMaxim Shaptala
 
Smart Gym System documentation
Smart Gym System documentationSmart Gym System documentation
Smart Gym System documentationTuvshinbayar Davaa
 
Dynamic Object-Oriented Requirements System (DOORS)
Dynamic Object-Oriented Requirements System (DOORS)Dynamic Object-Oriented Requirements System (DOORS)
Dynamic Object-Oriented Requirements System (DOORS)David Groff
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organizationTushar B Kute
 

Andere mochten auch (20)

Lecture-03 Introduction to UML
Lecture-03 Introduction to UMLLecture-03 Introduction to UML
Lecture-03 Introduction to UML
 
Class diagram
Class diagramClass diagram
Class diagram
 
Uml diagrams
Uml diagramsUml diagrams
Uml diagrams
 
Structured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and DesignStructured Vs, Object Oriented Analysis and Design
Structured Vs, Object Oriented Analysis and Design
 
4.class diagramsusinguml
4.class diagramsusinguml4.class diagramsusinguml
4.class diagramsusinguml
 
UML basic - Class Diagram
UML basic - Class DiagramUML basic - Class Diagram
UML basic - Class Diagram
 
Web 1.0, 2.0, 3.0
Web 1.0, 2.0, 3.0Web 1.0, 2.0, 3.0
Web 1.0, 2.0, 3.0
 
2 class use case
2 class use case2 class use case
2 class use case
 
Class diagram- UML diagram
Class diagram- UML diagramClass diagram- UML diagram
Class diagram- UML diagram
 
Object Modelling in Software Engineering
Object Modelling in Software EngineeringObject Modelling in Software Engineering
Object Modelling in Software Engineering
 
Difference between association, aggregation and composition
Difference between association, aggregation and compositionDifference between association, aggregation and composition
Difference between association, aggregation and composition
 
Unified Modelling Language
Unified Modelling LanguageUnified Modelling Language
Unified Modelling Language
 
class diagram
class diagramclass diagram
class diagram
 
01 introduction to entity framework
01   introduction to entity framework01   introduction to entity framework
01 introduction to entity framework
 
Ooad sequence diagram lecture
Ooad sequence diagram lectureOoad sequence diagram lecture
Ooad sequence diagram lecture
 
Class diagram, use case and sequence diagram
Class diagram, use case and sequence diagramClass diagram, use case and sequence diagram
Class diagram, use case and sequence diagram
 
Smart Gym System documentation
Smart Gym System documentationSmart Gym System documentation
Smart Gym System documentation
 
Dynamic Object-Oriented Requirements System (DOORS)
Dynamic Object-Oriented Requirements System (DOORS)Dynamic Object-Oriented Requirements System (DOORS)
Dynamic Object-Oriented Requirements System (DOORS)
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organization
 
Structured Analysis and Structured Design
Structured Analysis and Structured DesignStructured Analysis and Structured Design
Structured Analysis and Structured Design
 

Ähnlich wie Slide 5 Class Diagram

Ähnlich wie Slide 5 Class Diagram (20)

Relationships and their representation in a class diagram.pptx
Relationships and their representation in a class diagram.pptxRelationships and their representation in a class diagram.pptx
Relationships and their representation in a class diagram.pptx
 
06 class diagrams
06 class diagrams06 class diagrams
06 class diagrams
 
UML-class_diagram.ppt
UML-class_diagram.pptUML-class_diagram.ppt
UML-class_diagram.ppt
 
UML-class diagram for beginners to adance.ppt
UML-class diagram for beginners to adance.pptUML-class diagram for beginners to adance.ppt
UML-class diagram for beginners to adance.ppt
 
Software Testing and UML Lab
Software Testing and UML LabSoftware Testing and UML Lab
Software Testing and UML Lab
 
Session13-Class Diagram (1).pdf
Session13-Class Diagram (1).pdfSession13-Class Diagram (1).pdf
Session13-Class Diagram (1).pdf
 
210280107093_CLASS_DIAGRAM.pptx
210280107093_CLASS_DIAGRAM.pptx210280107093_CLASS_DIAGRAM.pptx
210280107093_CLASS_DIAGRAM.pptx
 
Advanced Structural Modeling
Advanced Structural ModelingAdvanced Structural Modeling
Advanced Structural Modeling
 
IBM OOAD Part1 Summary
IBM OOAD Part1 SummaryIBM OOAD Part1 Summary
IBM OOAD Part1 Summary
 
Different Types Diagrams
Different Types Diagrams  Different Types Diagrams
Different Types Diagrams
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering
 
UML Training for Business Analysts
UML Training for Business AnalystsUML Training for Business Analysts
UML Training for Business Analysts
 
Lecture 4-oop class diagram
Lecture 4-oop class diagramLecture 4-oop class diagram
Lecture 4-oop class diagram
 
Claas diagram
Claas diagramClaas diagram
Claas diagram
 
Claas diagram
Claas diagramClaas diagram
Claas diagram
 
classdiagram.pptx
classdiagram.pptxclassdiagram.pptx
classdiagram.pptx
 
Ooad lab manual
Ooad  lab manualOoad  lab manual
Ooad lab manual
 
Class diagram
Class diagramClass diagram
Class diagram
 
08 class and sequence diagrams
08   class and sequence diagrams08   class and sequence diagrams
08 class and sequence diagrams
 

Kürzlich hochgeladen

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 

Kürzlich hochgeladen (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 

Slide 5 Class Diagram

  • 2. What is a Class Diagram? • A Class Diagram is a diagram describing the structure of a system • shows the system's • classes • Attributes • Operations (or methods), • Relationships among the classes.
  • 3. What is a Class Diagram? • A class diagram depicts classes and their interrelationships • Used for describing structure and behavior in the use cases • Provide a conceptual model of the system in terms of entities and their relationships • Used for requirement capture, end-user interaction • Detailed class diagrams are used for developers
  • 4. Essential Elements of a UML Class Diagram • Class • Attributes • Operations • Relationships – Associations – Generalization – Realization – Dependency • Constraint Rules and Notes
  • 5. Class • Describes a set of objects having similar: – Attributes (status) – Operations (behavior) – Relationships with other classes • Graphically, a class is rendered as a rectangle, usually including its name, attributes, and operations in separate, designated compartments.
  • 6. Class Names The name of the class is the only required tag in the graphical representation of a class. It always appears in the top-most compartment.
  • 8. Class Attributes and Operations An attribute is a named property of a class that describes the object being modeled. In the class diagram, attributes appear in the second compartment just below the name-compartment. Attributes can be: + public # protected - private Attributes are usually listed in the form: attributeName : Type Operations describe the class behavior and appear in the third compartment.
  • 9. Visibility and Access for attributes and operations of a class
  • 10. Class Account_Name - Customer_Name - Balance +addFunds( ) +withDraw( ) +transfer( ) Name Attributes Operations
  • 11. Class Attributes and Operations Class Attributes:  The attribute type is shown after the colon.  Attributes map onto member variables (data members) in code. Class Operations (Methods):  The return type of a method is shown after the colon at the end of the method signature.  The type of method parameters are shown after the colon following the parameter name.  Operations map onto class methods in code
  • 12. Operation (Method) Parameter Directionality Parameter direction Description in states that p1 and p2 are passed to op1 by the caller. They are both in parameters. inout states that p3 is passed to op2 by the caller and is then possibly modified by op2 and is passed back out. p3 is an inout parameter. out states that p6 is not set by the caller but is modified by op3 and is passed back out. p6 is an out parameter.
  • 13. Association • In UML, object interconnections (logical or physical), are modeled as relationships. • An association between two classes indicates that objects at one end of an association “recognize” objects at the other end and may send messages to them. • Example: “An Employee works for a Company” Employee Company
  • 14. Association Relationships If two classes in a model need to communicate with each other, there must be link between them. An association denotes that link. InstructorStudent
  • 15. Association Relationships We can indicate the multiplicity of an association by adding multiplicity adornments to the line denoting the association. The example indicates that a Student has one or more Instructors: InstructorStudent 1..*
  • 16. Association Relationships The example indicates that every Instructor has one or more Students: InstructorStudent 1..*
  • 17. Association Relationships We can also indicate the behavior of an object in an association (i.e., the role of an object) using rolenames. InstructorStudent 1..*1..* learns fromteaches
  • 18. Association Relationships We can also name the association. TeamStudent membership 1..* 1..*
  • 19. Association Relationships We can specify dual associations. TeamStudent member of 1..* president of1 1..* 1..*
  • 20. Associations • Multiplicity – the number of objects that participate in the association. – Indicates whether or not an association is mandatory. Exactly one 1 Zero or more (unlimited) * (0..*) One or more 1..* Zero or one (optional association) 0..1 Specified range 2..4 Multiple, disjoint ranges 2, 4..6, 8 Multiplicity Indicators
  • 21. Association Relationships A class can have a self association. LinkedListNode next previous
  • 22. Aggregation • A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts. • A directional association between objects. • When an object ‘has-a’ another object, then you have got an aggregation between them. • Direction between them specified which object contains the other object. • It is also called ‘Has-a’ relationship.
  • 23. Aggregation  Class2 is part of Class1.  Many instances (denoted by the *) of Class2 can be associated with Class1.  Objects of Class1 and Class2 have separate lifetimes.
  • 24. Aggregation • Note: If you delete the parent object, even then the child object may exist. One object can contain the other, but there is no restriction that the composed object has to exist in order to have existence of child object.
  • 26. Composition • A strong form of aggregation • In a more specific manner, a restricted aggregation is called composition. – The whole is the sole owner of its part. • The part object may belong to only one whole – The life time of the part is dependent upon the whole. • The composite must manage the creation and destruction of its parts.
  • 27. Composition  Objects of Class2 live and die with Class1.  Class2 cannot stand by itself.
  • 28. Composition • A class contains students. A student cannot exist without a class. There exists composition between class and students.
  • 29. Difference between aggregation and composition • Composition is more restrictive. • When there is a composition between two objects, the composed object cannot exist without the other object. • This restriction is not there in aggregation. Though one object can contain the other object, there is no condition that the composed object must exist. • The existence of the composed object in aggregation is entirely optional.
  • 30. Difference between aggregation and composition • Example: A Library contains students and books. Relationship between library and student is aggregation. • Relationship between library and book is composition. – A student can exist without a library and therefore it is aggregation. – A book cannot exist without a library and therefore its a composition.
  • 31. Generalization Relationship o A generalization connects a subclass to its superclass. It denotes an inheritance of attributes and behavior from the superclass to the subclass and indicates a specialization in the subclass of the more general superclass. o “is kind of” relationship. Subtype2Subtype1 Supertype
  • 32. 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 operations Person Student
  • 33. Generalization Relationships UML permits a class to inherit from multiple superclasses, although some programming languages (e.g., Java) do not permit multiple inheritance. Student TeachingAssistant Employee
  • 36. Packages  UML provides an organizing element called a package.  Packages enable modelers to organize the model's classifiers into namespaces, which is sort of like folders in a filing system.  Dividing a system into multiple packages makes the system easier to understand, especially if each package represents a specific part of the system.
  • 37. Drawing Packages • There are two ways of drawing packages on diagrams. 1. If the modeler decides to show the package's members within the large rectangle, then all those members need to be placed within the rectangle.
  • 39. Drawing Packages 2. If the modeler decides to show the package's members outside the large rectangle then all the members that will be shown on the diagram need to be placed outside the rectangle. To show what classifiers belong to the package, a line is drawn from each classifier to a circle that has a plus sign inside the circle attached to the package
  • 41. Realization • A realization relationship indicates that one class implements a behavior specified by another class (an interface or protocol). • An interface can be realized by many classes. • A class may realize many interfaces. LinkedList <<interface>> List ArrayList
  • 42. Constraint Rules and Notes • Constraints and notes annotate among other things associations, attributes, operations and classes. • Constraints are semantic restrictions noted as Boolean expressions. – UML offers many pre-defined constraints. id: long { value > 0 } Customer Order *1 { total < $50 } may be canceled Constraint Note
  • 43. What is a Object Diagram? • Object diagrams represent an instance of a class diagram. • The purposes of object diagrams are similar to class diagrams. • The difference is that a class diagram represents an abstract model consisting of classes and their relationships. But an object diagram represents an instance at a particular moment which is concrete in nature.

Hinweis der Redaktion

  1. Syntax: visibility name (dir parameterName : type = default value, ... ) : returnType Parameter directions: in, out, inout or return Only name is mandatory in Analysis