class diagram.pptx
TRANSCRIPT
-
8/17/2019 Class Diagram.pptx
1/21
Class Diagram
SwapnilSoner
-
8/17/2019 Class Diagram.pptx
2/21
Class Diagram
• A class diagram is a schema, patternor templates for describing manypossible instances of data.
• Describes classes.
-
8/17/2019 Class Diagram.pptx
3/21
3
Instance diagram
• Describes how a particular set ofobjects relate to each other.
• Describes objects
-
8/17/2019 Class Diagram.pptx
4/21
4
erson
Class Diagram
!erson"#am
!erson" $ai
Instance Diagram
-
8/17/2019 Class Diagram.pptx
5/21
%
Attribute
• An attribute is a data value held bythe objects in a class.
• &ach attribute name is uni'ue withina class.
• An attribute should be a pure data(alue, not an object.
-
8/17/2019 Class Diagram.pptx
6/21
)
*bject +odeling otations
erson
name- stringage- integer
Class withAttributes
!erson"#am
4
!erson" $ai34
*bjects with /alues
-
8/17/2019 Class Diagram.pptx
7/21
0
*perations and +ethods
• An operation is a function ortransformation that may be applied toor by objects in a class.
•
All objects in a class share the sameoperations.
• 1he same operation may apply to manydi2erent classes.
•A method is the implementation of anoperation for a class.
-
8/17/2019 Class Diagram.pptx
8/21
erson
nameage
changejob
changeadd
erson
nameage
changejob
changeadd
erson
nameage
print
5ile
namesi6e
*perations
-
8/17/2019 Class Diagram.pptx
9/21
7
Association
• associations are the means forestablishing relationships among objectsand classes.
•
Associations are bidirectional.• In real, both directions of tra(ersal are
e'ually meaningful and refer to sameassociation.
• Associations are often implemented inprogramming languages as pointers fromone object to another.
•
A pointer is an attribute in one object thatcontains an e8 licit reference to another
-
8/17/2019 Class Diagram.pptx
10/21
9:
Countryname
Cityname
;ascapital
!Country"India
!City"Delhi
;ascapital
;ascapital
ClassDiagram
Instance Diagram
*neto*ne Association andlin
-
8/17/2019 Class Diagram.pptx
11/21
99
+ultiplicity
• It speci=es how many instances ofone class may relate to a singleinstance of an associated class.
• +ultiplicity depends uponassumptions and how you de=ne theboundaries of a problem.
-
8/17/2019 Class Diagram.pptx
12/21
9
#ole ames
• A role is one end of an association.
• A binary association has roles, each ofwhich may ha(e a role name.
•
A role name is a name that uni'uelyidenti=es one end of an association.
• #oles often appear as nouns in problemdescriptions.
• >se of role name is optional.• #ole names are necessary for associations
between two objects of the same class.
-
8/17/2019 Class Diagram.pptx
13/21
93
person companyemployee employer
?or
-
8/17/2019 Class Diagram.pptx
14/21
94
ordering
• If order of objects re'uired
• Indicated by writing @orderedBne8t to multiplicity dot for the role.
window screenorderedB
/isibleon
*rdered sets in an association
-
8/17/2019 Class Diagram.pptx
15/21
9%
uali=cation
• It relates two classes and a 'uali=er.
• uali=er is a special attribute that reducesthe e2ecti(e multiplicity of an association.
•
*netomany or manytomany may be'uali=ed that can be reduced to onetoone. ! but not always"
• It distinguishes among the set of objects at
the many end of an association.• A qualifed association can also be
considered a orm o ternary association.
-
8/17/2019 Class Diagram.pptx
16/21
9)
Directory
5ile5ile name
A 'uali=ed association
A directory plus a =le name yields a =le
-
8/17/2019 Class Diagram.pptx
17/21
90
Aggregation
• It is a partof relationship
• Aggregation is a special form ofassociation.
-
8/17/2019 Class Diagram.pptx
18/21
9
document paragraph sentence
Aggregation
-
8/17/2019 Class Diagram.pptx
19/21
-
8/17/2019 Class Diagram.pptx
20/21
-
8/17/2019 Class Diagram.pptx
21/21
&S& E +odeling *bjects and Classes
/isibility and Scope of 5eatures
Don’t worryaboutvisibility tooearly!
Don’t worryaboutvisibility tooearly!