远程教学支持系统
 
STUDENT
 
FACULTY
 
SCHOOL
 
SUPPORT
 
PUBLIC
 
SIGNUP
DAILY QUIZ
 
     
  B U L L E T I N    B O A R D

643 Week 9/15 Outline: Advanced Class Diagrams and Association Classes Implementation

(Subject: Systems Analysis/Authored by: Liping Liu on 3/14/2025 4:00:00 AM)/Views: 3764
Blog    News    Post   

Review: Homework

Continue: code ApplyInterest() function

 

Lecture 1: Advanced Association: Composition and Aggregation:

  • A special kinds of association that model object containment relationship (not class containment, why?)
  • Composition is stronger than aggregation: composition means exclusive containment whereas aggregation means shared containment
  • Examples: Car - Engine - Cylinder, Building-Room-Wall, Course -Section - Student - Prerequisite, Directory - File
  • Implementation:
    • C++ uses pointers for aggregation so that when the host is destroyed, the contained objects do not have to be destroyed
    • C++ uses regular variables for composition so that, when the host is destroyed, the contained objects will be destroyed too
    • Java/C# does not have the concept of pointers and so there is no difference in implementation

Lecture 2: Association Objects and Classes

  • It is used for capturing data that describe associations. There are two common cases to use associative classes
    • exist of attributes or data for associations, e.g., quantity of a product in each order, a grade earned by a student in each class
    • dynamic associations between two types of objects, e.g., hotel room reservations, meeting facility assignments. Of courses, in these cases, we can also create regular objects Reservations and Assignments instead of associative objects.  
  • It does not represent real world objects. It represents real-world relationships
  • Unlike ER diagrams which have associative entities only when the association is m:m. In class diagrams, associative classes are used for associations of any multiplicities. 
  • Example: Domestic Partnership between individuals and Marriage between men and women

Lecture 3: Implementation of Association Classes

  • Dictionary vs. List: A dictionary contains a list of values, with each having an index key value so that search for a list value is easier and faster. 

        Use of List::

            List values = new List();

            values.add(12.1);

            values.add(20.9);

            values.remove(12.1);

        Use of Dictionary:

            Dictionary<int, double> values = new Dictionary<int,double>();

            values.add(1,12.01);

            values.add(2,20.9);

            values.remove(1);

  • Navigability Flow: Object A knows associated objects if and only there is a directed flow for object A to those objects. Thus, if there is an associative object in one-direction association A ---> B, then A knows B as well as the associative objects, Associative class knows both objects of A and B classes, but B does not know A's objects and does not know associative objects
  • Use List<> for multiple valued attributes or Dictionary<key,value> for multivalued attributes with the need to search for a value in the list using a key. For example, Order class may have a list of products so we can use List type. If at the same time, we desire to have the capability to search for a product in the order, we can use Dictionary<string, Product>  instead of List so that we can search one product using product ID or SKU, which is of string type.

Example: Implement the following class diagram for an ecommerce system:

Reading: Chapter 7

Exercises: Correctness Questions: online; Closeness Questions: Q9 of Chapter 7


           Register

Blog    News    Post
 
     
 
Blog Posts    News Digest    Contact Us    About Developer    Privacy Policy

©1997-2025 ecourse.org. All rights reserved.