OO Concepts   «Prev  Next»
Lesson 3 Responsibilities and collaborators
Objective Describe the responsibilities and collaborators for the video store example.

Video Store Model: Class-Responsibility-Collaborator (CRC) Analysis

  1. Customer
    Responsibilities:
    1. Maintain personal details (e.g., name, address, contact number).
    2. Initiate a rental or reservation for a video.
    3. Return a rented video.
    4. Query personal rental and reservation history.
    5. Update personal details.

    Collaborators:
    1. Rental
    2. Reservation
    3. Inventory
    4. Video
  2. Inventory:
    Responsibilities:
    1. Keep track of the total number of video copies available for each title.
    2. Update video stock upon the acquisition of new titles or copies.
    3. Determine availability of a specific title for rental or reservation.
    4. Register a video as rented or reserved.
    5. Receive returned video copies and update stock availability.

    Collaborators:
    1. Title
    2. Video
    3. Rental
    4. Reservation
    5. Customer
  3. Rental:
    Responsibilities:
    1. Record details of a video rental transaction, including rental date, due date, and return date.
    2. Calculate rental charges based on rental duration.
    3. Handle video return and check for late returns to impose penalties if necessary.
    4. Update inventory upon video return.

    Collaborators:
    1. Customer
    2. Inventory
    3. Video
    4. Title
  4. Reservation:
    Responsibilities:
    1. Record details of a video reservation, including reservation date and expected pickup date.
    2. Check and update reservation status (e.g., reserved, picked up, expired).
    3. Notify customers when their reserved video is available for pickup.

    Collaborators:
    1. Customer
    2. Inventory
    3. Video
    4. Title
  5. Title:
    Responsibilities:
    1. Store information about a video title, such as title name, genre, release date, and synopsis.
    2. Provide a link between the abstract concept of a video title and its physical copies (Videos).
    3. Maintain a list of all video copies associated with the title.

    Collaborators:
    1. Video
    2. Inventory
    3. Rental
    4. Reservation
  6. Video
    Responsibilities:
    1. Represent a physical copy of a video title.
    2. Maintain details like copy ID, purchase date, and current status (e.g., available, rented, reserved).
    3. Link to the title it represents.
    4. Record which customer currently holds the video, if rented or reserved.

    Collaborators:
    1. Title
    2. Inventory
    3. Rental
    4. Reservation
    5. Customer

The six classes within the video store model interoperate through a network of responsibilities and collaborations. The clear demarcation of these roles ensures effective functioning of the entire system, reflecting real-world operations of a video store.
The video store example has six classes at the moment:
  1. Customer,
  2. Inventory,
  3. Rental,
  4. Reservation,
  5. Title, and
  6. Video.

Each class has certain responsibilities, such as tracking or recording information or making calculations. We distinguish between a title and a video because there may be several copies of a popular title in stock. Each video may be out or available, for example. Customers query about titles, though: They do not care whether copy 7 is available or not, as long as at least one copy is available.

Here is a summary of the responsibilities of each class:
  1. Customer: Tracks name, address, and phone number. Records payments and charges and keeps an account balance.
  2. Inventory: Keeps a list of titles. Finds available videos.
  3. Rental: Represents a rental transaction. Records duration, calculates charges, marks video as out, processes the return.
  4. Reservation: Represents a reservation of a title. Records customer and date, marks video as reserved.
  5. Title:Keeps a list of videos, finds available video. Knows charges for this title.
  6. Video: Tracks status (out, reserved, available).

You can see in these descriptions that classes collaborate to get things done.
The Rental class marks the video as out (rented), but that information is kept in the Video class, so on that responsibility, Video is a collaborator. When Inventory finds an available video, it does so by getting the Title class to collaborate. This kind of interaction is vital to any object-oriented application.

Video Store - Quiz

Click the Quiz link below to identify responsibilities and collaborators in the course project.
Video Store - Quiz