Specification of a Video Rental Store Point of Sale System

Domain Description

A video rental store has an inventory of recordings. Recordings can be rented and returned to the inventory. The inventory can be searched by film titles. The entire inventory can be printed, too. Each recording has a unique id number and a rental history that tells which customer rented it and for which period. Recordings include DVDs and video tapes.

Every recording is a recording of some film. Comedies, Dramas, Romances, Science Fiction, and Thrillers are types or genres of films. A film has a title, a short description, a director, a rating (excellent, good, fair, bad) and a cast of characters. A character has a name and an actor who plays the character. Actors, directors, and customers are persons. A person has a name. Customers also have an ID number, a telephone number, and a rental history.

Trilogy Video Rentals is highly specialized. They have 3 recordings of The Matrix (1 tape and 2 DVDs), 2 recordings of The Matrix Reloaded (1 tape and 1 DVD), and 1 DVD of Matrix Revolutions.

Model

The model can be downloaded here.

Domain Model

We divide our models into four packages. The general or conceptual domain model (called the T-Box) consists of two packages: videoRental and film. The concepts modeled in this package might be applicable to any video rental business. These models are class diagrams.

The specific domain model (called the A-Box) is contained in the packages trilogy and matrices. These are object diagrams that instantiate the class diagrams in the general domain model. These models are specific to the Trilogy Video Rentals.

The film Package

Here's the textual description of the film domain:

Comedies, Dramas, Romances, Science Fiction, and Thrillers are types or genres of films. A film has a title, a short description, a director, a rating (excellent, good, fair, bad) and a cast of characters. A character has a name and an actor who plays the character. Actors, directors, and customers are persons.

After textual analysis I have underlined important concepts and italicized important relationships.

Let's begin with:

A film has a title, description, director, and cast. A cast is a collection of characters. A character has a name and an actor who plays the character.

Obviously Film is an important concept and should be modeled by a class. We have a choice for title, description, cast, and director. These can be classes associated with Film or they can be Film attributes (but not both). To decide, we ask if the types of these concepts belong to the film domain. For example, the type of title and description is String, which is a general type that is not specific to any particular domain and therefore title and description should be attributes. Director might be of type Person, a general type, but following the Actor-Role pattern, we may want to separate the director role from the person who plays that role. In this case director is a type and a type specific to the film domain. A cast is obviously a domain-specific concept as are Character and Actor. Here's our film model so far:

Note the multiplicites. These were determined from common knowledge. Note, however, that there are a few mistakes. For example, one actor might play a character in his childhood and another might play the character as an adult.

We could have used aggregation to emphasize the fact that a cast is a collection of characters. If we decided that cast has no important properties beyond being a mere aggregation or composition of characters, we could have reduced it to the name of the association between Film and Character:

In this case we use aggregation to emphasize that characters can be shared by films. (Neo, for example.)

Films have ratings (excellent, good, fair, bad) and genres (Comedies, Dramas, Romances, Science Fiction, and Thrillers). We can interpret genres and ratings as types of films. We can model types as classes or objects. For example, here is how we might represent types as classes:

But what about a movie like The Matrix, which is an excellent science fiction film. Must we have two objects representing it, one an instance of Excellent the other an instance of Science Fiction? This can be awkward if films have changeable attributes like show times. In this case we will have to update two objects.

Here's what the model looks like if we construe types as objects:

Note the use of enumerations. Enumerations should be used if the number of types is small and membership is relatively stable.

To finish the film package we use the Actor-Role pattern to distinguish persons from the roles they play. This relationship is analogous to but not the same as the relationship between actors and the roles or characters that they play. For example, Keanu Reeves is a person. He plays many roles: actor, husband, father, etc. In his role as actor he plays many characters: Neo, Ted, Buddha, etc.

To begin, let's import a foundation package into our model:

The foundation package contains utility classes/types useful to all models. For example: String, Number, Money, Date, Set, Person, etc.

Note that Role is an abstract class (because it's italicized). We consider Director and Actor to be types of roles. We could have represented them as instances of the Role class rather than subclasses. We also could have suppressed mention of the Person class and simply modeled this as attributes of director and actor:

The video rental Package

Here's the textual description of the video rental domain:

A video rental store has an inventory of recordings. Recordings can be rented and returned to the inventory. The inventory can be searched by film titles. The entire inventory can be printed, too. Each recording has a unique id number and a rental history that tells which customer rented it and for which period. Recordings include DVDs and video tapes. Every recording is a recording of some film ...

The underlined phrases should be classes. Italicized phrases should be dependencies (associations, generalizations, aggregations, etc.). Those phrases that are both underlined and italicized sound like operations, but of what class? This is really a design decision. We look ahead a bit and assume rent, return, search, and print are inventory operations. To support the rent and return operation we add a rented attribute to recording with initial value false.

Note that DVD and Tape are types of recordings. Because they may have different properties and operations (for example, tapes can be rewound while DVDs cannot) we choose to represent them as classes rather than objects.

Note that the uniqueness of a recording's id is expressed using a constraint. Constraints are Boolean expressions surrounded by curly braces. The Object Constraint Language (OCL) formalizes this language.

For most business it is important to keep track of all transactions: sales, purchases, rentals, etc. Transactions are examples of events. Events are objects, too. In this example renting a recording is an event. Its representation records when the recording was rented, who rented it, and when it is due back. A history is a collection of these events. Every recording has an associated history:

If History seems like it will be a lazy class—i.e., it won't have any responsibilities or properties other than to hold rentals, then we may choose to make it an attribute:

Customer can be added to the roles a person can play:

The matrices Package

Here's a description of the Matrix domain:

So far there are three films in the Matrix series: The Matrix, The Matrix Reloaded, and Matrix Revolutions. The first movie was excellent, the other two were only fair. All three films feature the characters Trinity (played by Carrie-Ann Moss,) Neo (palyed by Keanu Reeves,) and Morpheus (played by Lawrence Fishburn). All three films were directed by Andy and Larry Wachowski.

Here's an object diagram representing this domain:

 

 

Note: directors not shown due to space limitations.

Note FAIR and SCIENCE FICTION are shared objects.

The trilogy Package

Here's the textual description of the trilogy domain:

Trilogy Video Rentals is highly specialized. They have 3 recordings of The Matrix (1 tape and 2 DVDs), 2 recordings of The Matrix Reloaded (1 tape and 1 DVD), and 1 DVD of Matrix Revolutions.

Here's an object diagram representing this domain: