SlideShare a Scribd company logo
1 of 50
Arab Open University
2nd
Semester, 2006-2007
M301
Unit 4.3
Classes and Associations
reem.attas@arabou.org.sa
Reem AlAttas © 2
Topic Road Map
 Simple class models with the UML
Precise modeling of associations
More modeling techniques
Constraining models
Reem AlAttas © 3
Class Model
Describes the objects and the
relationships between them that are
needed to implement the required
functionality.
Reem AlAttas © 4
Searching for Classes
 Tangible objects: the physical things in the domain.
 Ex. rooms, bills, books, vehicles.
 Roles: the roles played by people in the domain.
 Ex. employee, guest, member.
 Events: the circumstances, episodes, interactions,
happenings or significant incidents.
 Ex. reservation of a room, the registration of a vehicle, orders,
deliveries and transactions.
 Organizational units: the groups to which people belong.
 Ex. accounts department, a production team or a maintenance
crew.
Reem AlAttas © 5
… Searching for Classes
The focus on looking for nouns in a
problem description design does
emphasize that you are concentrating on
things.
In a traditional procedural model, the first
area of concern would instead have been
actions and activities, which are described
by verbs.
Reem AlAttas © 6
Object Diagram
Model that show a number of concrete
instances of a set of relevant classes and
the relationships between them.
Each object is an instance of a class.
Each link is an instance of an association.
Reem AlAttas © 7
… Object Diagram
Reem AlAttas © 8
Object Diagram with Role Names
Reem AlAttas © 9
Class Diagrams
A model that expresses generalizations
about all valid object diagrams.
Box represent class.
Line represent association.
Reem AlAttas © 10
Class and some instances
Reem AlAttas © 11
Associations
 The relationships between classes  How
classes might be related?
 A Guest is related to:
 A Hotel by making a reservation.
 A Room by currently occupying a room or having stayed
in a room previously.
 A Room is related to a Hotel by being physically
located in a Hotel.
Reem AlAttas © 12
… Associations
Reem AlAttas © 13
Multiplicities
How many of one sort of thing can be
related to another sort of thing 
determine how many objects are required.
minimum .. maximum
Reem AlAttas © 14
… Multiplicities
Reem AlAttas © 15
… Multiplicities
Reem AlAttas © 16
Naming Associations
Reem AlAttas © 17
Role Names
Reem AlAttas © 18
Two Associations
Reem AlAttas © 19
Several Associations
Reem AlAttas © 20
Recursive Relationship
Reem AlAttas © 21
Topic Road Map
Simple class models with the UML
 Precise modeling of associations
More modeling techniques
Constraining models
Reem AlAttas © 22
Aggregation
A whole–part relationship.
 Ex. The whole (an invoice) is made up from the
parts (the invoice lines).
It is possible to add, remove or replace
one of the ‘parts’ and still have a
meaningful relationship: an invoice would
still be an aggregation of invoice lines if
another invoice line were to be added.
Reem AlAttas © 23
Composition
A chess-board and its squares are much
more intimately related than an invoice
and its invoice lines because a chess
board cannot exist unless it has 64
squares.
If you were to remove (or add) a square
you would no longer have a recognizable
chess-board.
Reem AlAttas © 24
… Composition
Reem AlAttas © 25
Navigation
Put an open arrowhead at one or both
ends of an association to indicate that it is
possible to reach one class from another
following the direction of the arrow.
Reem AlAttas © 26
… Navigation
An instance of the class Invoice can send
messages to instances of the class
InvoiceLine, but not the other way round.
Reem AlAttas © 27
Qualified Associations
If the system you are modeling includes a
mechanism for identifying objects
uniquely, you can use qualified
associations to record this information.
In cases where objects can be uniquely
identified by combinations of two or more
attributes, all those attributes should move
into the qualifier.
Reem AlAttas © 28
… Qualified Associations
Reem AlAttas © 29
Derived Associations
Associations can be derived from others
already in that diagram.
By preceding a role name with a slash,
you indicate that an association is
derivable.
Reem AlAttas © 30
… Derived Associations
Reem AlAttas © 31
Topic Road Map
Simple class models with the UML
Precise modeling of associations
 More modeling techniques
Constraining models
Reem AlAttas © 32
Generalization and Specialization
Reem AlAttas © 33
… Generalization and Specialization
Superclass  more general element.
Subclass  more specific element.
A subclass has the same attributes as the
superclass, though it may define some
additional ones.
Reem AlAttas © 34
Specialization of Account
Reem AlAttas © 35
Interface
the set of operations that specify the
service that a class provides.
 Ex. The class Account has the interface {credit
(amount: Money), debit (amount: Money),
getBalance ()} while the class SavingsAccount
has the interface {credit (amount: Money), debit
(amount: Money), getBalance (), addInterest ()}.
Reem AlAttas © 36
Multiple Levels of Specialization
Reem AlAttas © 37
Violating the is-a rule
Reem AlAttas © 38
Inventing a Superclass
<<abstract>>  never be used to create
instances.
Reem AlAttas © 39
Polymorphism
The ability to use instances of various
different classes through a shared
interface.
The interface simply identifies a set of
operations by naming each one. It does
not provide any implementation.
Reem AlAttas © 40
… Polymorphism
Reem AlAttas © 41
Dependency
Reem AlAttas © 42
Topic Road Map
Simple class models with the UML
Precise modeling of associations
More modeling techniques
 Constraining models
Reem AlAttas © 43
Constraints
Invariants: Boolean expressions that must
always remain true.
 Ex. valid account numbers need to be within a
certain range.
Reem AlAttas © 44
… Constraints
Reem AlAttas © 45
Object Constraint Language (OCL)
Combines logical expressions with set
notation to allow a more rigorous
specification of a constraint.
Reem AlAttas © 46
Constraints across Associations
Reem AlAttas © 47
Controlling the Use of Different
Accounts
Reem AlAttas © 48
Constraint on Related Objects
TMA4 – Q3
Thank You!

More Related Content

Similar to Classes and Associations

Similar to Classes and Associations (20)

se_lectures.DS_Store__MACOSXse_lectures._.DS_Storese_
se_lectures.DS_Store__MACOSXse_lectures._.DS_Storese_se_lectures.DS_Store__MACOSXse_lectures._.DS_Storese_
se_lectures.DS_Store__MACOSXse_lectures._.DS_Storese_
 
Interactions
InteractionsInteractions
Interactions
 
Uml class Diagram
Uml class DiagramUml class Diagram
Uml class Diagram
 
CS8592-OOAD-UNIT II-STATIC UML DIAGRAMS PPT
CS8592-OOAD-UNIT II-STATIC UML DIAGRAMS PPTCS8592-OOAD-UNIT II-STATIC UML DIAGRAMS PPT
CS8592-OOAD-UNIT II-STATIC UML DIAGRAMS PPT
 
Uml - An Overview
Uml - An OverviewUml - An Overview
Uml - An Overview
 
Fundamentals of Software Engineering
Fundamentals of Software Engineering Fundamentals of Software Engineering
Fundamentals of Software Engineering
 
Types of UML diagrams
Types of UML diagramsTypes of UML diagrams
Types of UML diagrams
 
CASE Tools lab.ppt
CASE Tools lab.pptCASE Tools lab.ppt
CASE Tools lab.ppt
 
Intro Uml
Intro UmlIntro Uml
Intro Uml
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 
2 class use case
2 class use case2 class use case
2 class use case
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
Ch 3.pdf
Ch 3.pdfCh 3.pdf
Ch 3.pdf
 
ch3.ppt
ch3.pptch3.ppt
ch3.ppt
 
4. UML
4. UML4. UML
4. UML
 

More from Reem Alattas

Rumble Lights Pitch Deck
Rumble Lights Pitch DeckRumble Lights Pitch Deck
Rumble Lights Pitch DeckReem Alattas
 
NASA Datanauts Water Cooler Chat: Autonomous Design of Modular Robots
NASA Datanauts Water Cooler Chat: Autonomous Design of Modular RobotsNASA Datanauts Water Cooler Chat: Autonomous Design of Modular Robots
NASA Datanauts Water Cooler Chat: Autonomous Design of Modular RobotsReem Alattas
 
She looks just like me 2017
She looks just like me 2017She looks just like me 2017
She looks just like me 2017Reem Alattas
 
Nasa Datanauts Water Cooler Chat: Robotics for Space Exploration
Nasa Datanauts Water Cooler Chat: Robotics for Space ExplorationNasa Datanauts Water Cooler Chat: Robotics for Space Exploration
Nasa Datanauts Water Cooler Chat: Robotics for Space ExplorationReem Alattas
 
Nasa Datanauts Water Cooler Chat: Evolutionary Robots for Space Exploration
Nasa Datanauts Water Cooler Chat: Evolutionary Robots for Space ExplorationNasa Datanauts Water Cooler Chat: Evolutionary Robots for Space Exploration
Nasa Datanauts Water Cooler Chat: Evolutionary Robots for Space ExplorationReem Alattas
 
She Looks Just Like Me 2017
She Looks Just Like Me 2017She Looks Just Like Me 2017
She Looks Just Like Me 2017Reem Alattas
 
Evolutionary Robotics
Evolutionary RoboticsEvolutionary Robotics
Evolutionary RoboticsReem Alattas
 
Enhancing input on and above the interactive surface
Enhancing input on and above the interactive surfaceEnhancing input on and above the interactive surface
Enhancing input on and above the interactive surfaceReem Alattas
 
Skinput: Appropriating the Body as an Input Surface
Skinput: Appropriating the Body as an Input SurfaceSkinput: Appropriating the Body as an Input Surface
Skinput: Appropriating the Body as an Input SurfaceReem Alattas
 
XML - EXtensible Markup Language
XML - EXtensible Markup LanguageXML - EXtensible Markup Language
XML - EXtensible Markup LanguageReem Alattas
 
Dynamic HTML Event Model
Dynamic HTML Event ModelDynamic HTML Event Model
Dynamic HTML Event ModelReem Alattas
 
DHTML - Dynamic HTML
DHTML - Dynamic HTMLDHTML - Dynamic HTML
DHTML - Dynamic HTMLReem Alattas
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript ObjectsReem Alattas
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary SearchReem Alattas
 
JavaScript Arrays
JavaScript Arrays JavaScript Arrays
JavaScript Arrays Reem Alattas
 
JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions Reem Alattas
 
JavaScript Control Statements II
JavaScript Control Statements IIJavaScript Control Statements II
JavaScript Control Statements IIReem Alattas
 
JavaScript Control Statements I
JavaScript Control Statements IJavaScript Control Statements I
JavaScript Control Statements IReem Alattas
 

More from Reem Alattas (20)

Rumble Lights Pitch Deck
Rumble Lights Pitch DeckRumble Lights Pitch Deck
Rumble Lights Pitch Deck
 
NASA Datanauts Water Cooler Chat: Autonomous Design of Modular Robots
NASA Datanauts Water Cooler Chat: Autonomous Design of Modular RobotsNASA Datanauts Water Cooler Chat: Autonomous Design of Modular Robots
NASA Datanauts Water Cooler Chat: Autonomous Design of Modular Robots
 
She looks just like me 2017
She looks just like me 2017She looks just like me 2017
She looks just like me 2017
 
Nasa Datanauts Water Cooler Chat: Robotics for Space Exploration
Nasa Datanauts Water Cooler Chat: Robotics for Space ExplorationNasa Datanauts Water Cooler Chat: Robotics for Space Exploration
Nasa Datanauts Water Cooler Chat: Robotics for Space Exploration
 
Nasa Datanauts Water Cooler Chat: Evolutionary Robots for Space Exploration
Nasa Datanauts Water Cooler Chat: Evolutionary Robots for Space ExplorationNasa Datanauts Water Cooler Chat: Evolutionary Robots for Space Exploration
Nasa Datanauts Water Cooler Chat: Evolutionary Robots for Space Exploration
 
She Looks Just Like Me 2017
She Looks Just Like Me 2017She Looks Just Like Me 2017
She Looks Just Like Me 2017
 
Tran helmet pitch
Tran helmet pitchTran helmet pitch
Tran helmet pitch
 
Evolutionary Robotics
Evolutionary RoboticsEvolutionary Robotics
Evolutionary Robotics
 
Create a Need
Create a NeedCreate a Need
Create a Need
 
Enhancing input on and above the interactive surface
Enhancing input on and above the interactive surfaceEnhancing input on and above the interactive surface
Enhancing input on and above the interactive surface
 
Skinput: Appropriating the Body as an Input Surface
Skinput: Appropriating the Body as an Input SurfaceSkinput: Appropriating the Body as an Input Surface
Skinput: Appropriating the Body as an Input Surface
 
XML - EXtensible Markup Language
XML - EXtensible Markup LanguageXML - EXtensible Markup Language
XML - EXtensible Markup Language
 
Dynamic HTML Event Model
Dynamic HTML Event ModelDynamic HTML Event Model
Dynamic HTML Event Model
 
DHTML - Dynamic HTML
DHTML - Dynamic HTMLDHTML - Dynamic HTML
DHTML - Dynamic HTML
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary Search
 
JavaScript Arrays
JavaScript Arrays JavaScript Arrays
JavaScript Arrays
 
JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions
 
JavaScript Control Statements II
JavaScript Control Statements IIJavaScript Control Statements II
JavaScript Control Statements II
 
JavaScript Control Statements I
JavaScript Control Statements IJavaScript Control Statements I
JavaScript Control Statements I
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Classes and Associations

  • 1. Arab Open University 2nd Semester, 2006-2007 M301 Unit 4.3 Classes and Associations reem.attas@arabou.org.sa
  • 2. Reem AlAttas © 2 Topic Road Map  Simple class models with the UML Precise modeling of associations More modeling techniques Constraining models
  • 3. Reem AlAttas © 3 Class Model Describes the objects and the relationships between them that are needed to implement the required functionality.
  • 4. Reem AlAttas © 4 Searching for Classes  Tangible objects: the physical things in the domain.  Ex. rooms, bills, books, vehicles.  Roles: the roles played by people in the domain.  Ex. employee, guest, member.  Events: the circumstances, episodes, interactions, happenings or significant incidents.  Ex. reservation of a room, the registration of a vehicle, orders, deliveries and transactions.  Organizational units: the groups to which people belong.  Ex. accounts department, a production team or a maintenance crew.
  • 5. Reem AlAttas © 5 … Searching for Classes The focus on looking for nouns in a problem description design does emphasize that you are concentrating on things. In a traditional procedural model, the first area of concern would instead have been actions and activities, which are described by verbs.
  • 6. Reem AlAttas © 6 Object Diagram Model that show a number of concrete instances of a set of relevant classes and the relationships between them. Each object is an instance of a class. Each link is an instance of an association.
  • 7. Reem AlAttas © 7 … Object Diagram
  • 8. Reem AlAttas © 8 Object Diagram with Role Names
  • 9. Reem AlAttas © 9 Class Diagrams A model that expresses generalizations about all valid object diagrams. Box represent class. Line represent association.
  • 10. Reem AlAttas © 10 Class and some instances
  • 11. Reem AlAttas © 11 Associations  The relationships between classes  How classes might be related?  A Guest is related to:  A Hotel by making a reservation.  A Room by currently occupying a room or having stayed in a room previously.  A Room is related to a Hotel by being physically located in a Hotel.
  • 12. Reem AlAttas © 12 … Associations
  • 13. Reem AlAttas © 13 Multiplicities How many of one sort of thing can be related to another sort of thing  determine how many objects are required. minimum .. maximum
  • 14. Reem AlAttas © 14 … Multiplicities
  • 15. Reem AlAttas © 15 … Multiplicities
  • 16. Reem AlAttas © 16 Naming Associations
  • 17. Reem AlAttas © 17 Role Names
  • 18. Reem AlAttas © 18 Two Associations
  • 19. Reem AlAttas © 19 Several Associations
  • 20. Reem AlAttas © 20 Recursive Relationship
  • 21. Reem AlAttas © 21 Topic Road Map Simple class models with the UML  Precise modeling of associations More modeling techniques Constraining models
  • 22. Reem AlAttas © 22 Aggregation A whole–part relationship.  Ex. The whole (an invoice) is made up from the parts (the invoice lines). It is possible to add, remove or replace one of the ‘parts’ and still have a meaningful relationship: an invoice would still be an aggregation of invoice lines if another invoice line were to be added.
  • 23. Reem AlAttas © 23 Composition A chess-board and its squares are much more intimately related than an invoice and its invoice lines because a chess board cannot exist unless it has 64 squares. If you were to remove (or add) a square you would no longer have a recognizable chess-board.
  • 24. Reem AlAttas © 24 … Composition
  • 25. Reem AlAttas © 25 Navigation Put an open arrowhead at one or both ends of an association to indicate that it is possible to reach one class from another following the direction of the arrow.
  • 26. Reem AlAttas © 26 … Navigation An instance of the class Invoice can send messages to instances of the class InvoiceLine, but not the other way round.
  • 27. Reem AlAttas © 27 Qualified Associations If the system you are modeling includes a mechanism for identifying objects uniquely, you can use qualified associations to record this information. In cases where objects can be uniquely identified by combinations of two or more attributes, all those attributes should move into the qualifier.
  • 28. Reem AlAttas © 28 … Qualified Associations
  • 29. Reem AlAttas © 29 Derived Associations Associations can be derived from others already in that diagram. By preceding a role name with a slash, you indicate that an association is derivable.
  • 30. Reem AlAttas © 30 … Derived Associations
  • 31. Reem AlAttas © 31 Topic Road Map Simple class models with the UML Precise modeling of associations  More modeling techniques Constraining models
  • 32. Reem AlAttas © 32 Generalization and Specialization
  • 33. Reem AlAttas © 33 … Generalization and Specialization Superclass  more general element. Subclass  more specific element. A subclass has the same attributes as the superclass, though it may define some additional ones.
  • 34. Reem AlAttas © 34 Specialization of Account
  • 35. Reem AlAttas © 35 Interface the set of operations that specify the service that a class provides.  Ex. The class Account has the interface {credit (amount: Money), debit (amount: Money), getBalance ()} while the class SavingsAccount has the interface {credit (amount: Money), debit (amount: Money), getBalance (), addInterest ()}.
  • 36. Reem AlAttas © 36 Multiple Levels of Specialization
  • 37. Reem AlAttas © 37 Violating the is-a rule
  • 38. Reem AlAttas © 38 Inventing a Superclass <<abstract>>  never be used to create instances.
  • 39. Reem AlAttas © 39 Polymorphism The ability to use instances of various different classes through a shared interface. The interface simply identifies a set of operations by naming each one. It does not provide any implementation.
  • 40. Reem AlAttas © 40 … Polymorphism
  • 41. Reem AlAttas © 41 Dependency
  • 42. Reem AlAttas © 42 Topic Road Map Simple class models with the UML Precise modeling of associations More modeling techniques  Constraining models
  • 43. Reem AlAttas © 43 Constraints Invariants: Boolean expressions that must always remain true.  Ex. valid account numbers need to be within a certain range.
  • 44. Reem AlAttas © 44 … Constraints
  • 45. Reem AlAttas © 45 Object Constraint Language (OCL) Combines logical expressions with set notation to allow a more rigorous specification of a constraint.
  • 46. Reem AlAttas © 46 Constraints across Associations
  • 47. Reem AlAttas © 47 Controlling the Use of Different Accounts
  • 48. Reem AlAttas © 48 Constraint on Related Objects