Chapter 9 - Implementing Association Relationships1 Chapter 9 Implementing Association Relationships.

Slides:



Advertisements
Similar presentations
Chapter 4 - Object-Oriented Analysis and Design in a Nutshell1 Chapter 4 Object-Oriented Analysis and Design in a Nutshell.
Advertisements

Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
Chapter 11: Implementing Inheritance and Association Visual Basic.NET Programming: From Problem Analysis to Program Design.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Object-Oriented.
1 Composition A whole-part relationship (e.g. Dog-Tail) Whole and part objects have same lifetime –Whole creates instance of part in its constructor In.
Lecture 12: Chapter 22 Topics: UML (Contd.) –Relationship Structural Behavioral –Diagram Structural Behavioral.
1 CS 426 Senior Projects Chapter 9: Relationships Chapter 10: Inheritance and Polymorphism [Arlow and Neustadt, 2005] February 12, 2009.
Design Patterns in Java Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
CS 425/625 Software Engineering System Models
Object-Oriented Application Development Using VB.NET 1 Creating a String Array Code to create a String array: ' declare a String array with 4 elements.
1 CS 426 Senior Projects Chapter 9: Relationships Chapter 10: Inheritance and Polymorphism [Arlow and Neustadt, 2002] February 27, 2007.
Object-Oriented Application Development Using VB.NET 1 Chapter 9 Implementing Association Relationships.
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
CS708 Fall 2004 Professor Douglas Moody –MW – 2:15-3:55 pm –Friday – 6:00-9:20 pm – – –Web Site: websupport1.citytech.cuny.edu.
Chapter 7 - Generalization/Specialization and Inheritance1 Chapter 7 Generalization/Specialization and Inheritance.
Chapter 15 - Creating More Complex Database Applications 1 Chapter 15 Creating More Complex Database Applications.
The Unified Modeling Language (UML) Class Diagrams.
Object-Oriented Analysis and Design
 2008 Pearson Education, Inc. All rights reserved (Optional) Software Engineering Case Study: Identifying the Classes in the ATM Requirements.
Entity-Relationship modeling Transparencies
Chapter 5 - Writing a Problem Domain Class Definition1 Chapter 5 Writing a Problem Domain Class Definition.
Chapter 5 Entity–Relationship Modeling
Principles of Database Systems With Internet and Java Applications Today’s Topic Chapter 2: Representing Information with Data Models The lecture notes.
Copyright (c) 2014 Pearson Education, Inc. Introduction to Databases.
DATABASEMODELSDATABASEMODELS  A database model ◦ defines the logical design of data. ◦ Describes the relationships between different parts of data.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Lab 04.
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 15 System Modeling with the UML.
Chapter 12 - Designing Multiwindow Applications1 Chapter 12 Designing Multiwindow Applications 12.
Chapter 16 Applying UML and Patterns Craig Larman
The Static Analysis Model Class Diagrams Prof. Hany H. Ammar, CSEE, WVU, and Dept. of Computer Science, Faculty of Computers and Information, Cairo University.
Object-Oriented Application Development Using VB.NET 1 Chapter 6 Writing a Problem Domain Class Definition.
Chapter 8 - Additional Inheritance Concepts and Techniques1 Chapter 8 Additional Inheritance Concepts and Techniques.
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.
NJIT UML Class Diagrams Chapter 16 Applying UML and Patterns Craig Larman.
Carmen David, Senior BA Business Analysis Carmen David, Senior BA Business Analysis Foundation in Business Analysis Session 7 MODELLING REQUIREMENTS.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Object Oriented Software Development
Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
Class and Sequence diagrams UML notation SE-2030 Dr. Mark L. Hornick 1.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
Object Oriented Analysis and Design Class and Object Diagrams.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
UML Class Diagram notation Indicating relationships between classes SE-2030 Dr. Mark L. Hornick 1.
Chapter 16: UML Class Diagrams
Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
Chapter 3: Introducing the UML
Chapter 6 - More About Problem Domain Classes1 Chapter 6 More About Problem Domain Classes.
Object-Oriented Application Development Using VB.NET 1 Chapter 9 Implementing Association Relationships.
CLASS DIAGRAMS A classy approach to objects. The Basic Class Diagram  Class Name  Attributes (- indicates private each would have properties or accessor/mutator.
Object-Oriented Application Development Using VB.NET 1 Chapter 11 Using Multiple Forms with Problem Domain Classes.
UML Fundamental Elements. Structural Elements Represent abstractions in our system. Elements that encapsulate the system's set of behaviors. Structural.
Class Diagrams Revisited. Parameterized Classes Parameterized Classes - are used to represent relationships between templates.
Chapter 9: Relationships Chapter 10: Inheritance and Polymorphism [Arlow and Neustadt, 2005] CS 426 Senior Projects in Computer Science University of Nevada,
Object-Oriented Application Development Using VB.NET 1 Chapter 15 Assembling a Three-Tier Windows Application.
1 Chapter 13: Class Diagram Chapter 19 in Applying UML and Patterns Book.
Week 13: Wrap-up Refining Class Diagram and Implementation
CS 426 Senior Projects Chapter 9: Relationships
UML Class Diagram.
Chapter 20 Object-Oriented Analysis and Design
Creating More Complex Database Applications
Chapter 2 Role of Information Systems in Organizations Link 2
Information System Design
Week 15: Refining Class Diagram and Implementation
Chapter 11: Class Diagram
Presentation transcript:

Chapter 9 - Implementing Association Relationships1 Chapter 9 Implementing Association Relationships

Chapter 9 - Implementing Association Relationships2 Chapter 9 Topics Review of Bradshaw Marina’s class diagram Implementing association relationships with one-to-one multiplicity between Java classes Navigating from one instance to another when there is a one-to-one relationship Using the Vector class to create association relationships with one-to-many multiplicity between Java classes Navigating one-to-many association relationships using methods of the Vector class Creating and using an association class with Java

Chapter 9 - Implementing Association Relationships3 Reviewing Bradshaw Marina’s Class Diagram See Figure 9-1 Association relationships –Depict how instances of the classes are associated or connected to one another –Shown on the class diagram as lines connecting classes –Indicate that the system requires information about these associations

Chapter 9 - Implementing Association Relationships4 Reviewing Bradshaw Marina’s Class Diagram Association relationships –Can be shown as: Aggregation relationships –Strong association where one instance “contains” the other »E.g., town contains shopping centers or stores Composition relationships –Strong association where one is composed of, or “part of” another »E.g., walls that are part of a building

Chapter 9 - Implementing Association Relationships5 Associating Customer with Boat: One- to-One Association Relationship Each direction of the association relationship must be defined in Java –Mandatory / optional –Multiplicity To implement in Java: –Use a reference variable of one class as an attribute of another class

Chapter 9 - Implementing Association Relationships6

7 Associating Customer with Boat: One- to-One Association Relationship Modifying the Customer Class –To implement a one-to-one association with the Boat class: Add an attribute to Customer that holds a reference to a Boat instance (Figure 9-3) –TesterOneA (Figure 9-4) Tests one direction of association relationship –A Customer owns a Boat –Sequence diagram Illustrates the interaction in TesterOneA

Chapter 9 - Implementing Association Relationships8

9 Associating Customer with Boat: One- to-One Association Relationship Modifying the Boat Class –To implement a one-to-one association with the Customer class: (Figure 9-7) Add an attribute to Boat that holds a reference to a Customer instance Add accessor methods to establish the association relationship in both directions –TesterOneB (Figure 9-8) Tests both directions of association relationship –A Customer owns a Boat –A Boat is owned by a Customer

Chapter 9 - Implementing Association Relationships10 Adding Capability to the Boat Class Techniques to increase functionality –Make relationship mandatory rather than optional (pp. 291) E.g., when Boat is instantiated, it could require that a Customer be specified –Thus, only Boats owned by Customers of the business would be accepted into the system –Modify the Boat’s tellAboutSelf method (pp. 292) Return information about both Boat and Customer

Chapter 9 - Implementing Association Relationships11

Chapter 9 - Implementing Association Relationships12

Chapter 9 - Implementing Association Relationships13

Chapter 9 - Implementing Association Relationships14

Chapter 9 - Implementing Association Relationships15 Associating Dock and Slip: A One-to- Many Association Relationship Dock / Slip Relationships –Slip and Dock relationship A slip is attached to a dock One-to-One relationship –Similar to Customer and Boat relationship –Dock and Slip relationship A dock contains many slips One-to-Many relationship –Requires different approach

Chapter 9 - Implementing Association Relationships16 Associating Dock and Slip: A One-to- Many Association Relationship Introducing the Dock Class –Contains: A Vector attribute –Implements the one-to-many relationship A method that returns the Vector attribute reference

Chapter 9 - Implementing Association Relationships17

Chapter 9 - Implementing Association Relationships18

Chapter 9 - Implementing Association Relationships19 Associating Dock and Slip: A One-to- Many Association Relationship Associating the Slip Class With Dock (Figure 9-15) –Modified much like Boat class to implement a mandatory one-to-one association relationship Associates slip with dock –Further modified to also set up a relationship with a Boat Associates slip with boat

Chapter 9 - Implementing Association Relationships20 Associating Dock and Slip: A One-to- Many Association Relationship Testing the ‘Dock Contains Slips’ Association Relationship –TesterThreeA (Figure 9-16) Tests both directions of association relationship –One-to-Many »A Dock has multiple Slips –One-to-one »A Slip resides in a Dock

Chapter 9 - Implementing Association Relationships21

Chapter 9 - Implementing Association Relationships22

Chapter 9 - Implementing Association Relationships23 Associating Dock and Slip: A One-to- Many Association Relationship Adding the Boat and Customer Classes to the Example –To complete example (Figure 9-18): Modify Boat to associate with a Slip Add Customer class –TesterThreeB (Figure 9-19) Provides a comprehensive test of associations –Sequence diagram (Figure 9-20) Illustrates the interaction in TesterThreeB

Chapter 9 - Implementing Association Relationships24

Chapter 9 - Implementing Association Relationships25

Chapter 9 - Implementing Association Relationships26 Creating and Using an Association Class - Lease Association class –Lease is an association between a customer and a slip, but with additional attributes to characterize the lease agreement –To implement (Figure 9-23): Lease modified to include Slip and Customer reference attributes Slip modified to include a Lease reference attribute –Class diagram (Figure 9-22) Shows relationships between classes –TesterFour (Figure 9-26) Provides a comprehensive test of overall Lease associations –Sequence diagram Illustrates the interaction in TesterFour

Chapter 9 - Implementing Association Relationships27

Chapter 9 - Implementing Association Relationships28

Chapter 9 - Implementing Association Relationships29