CSC/ECE 517 Summer 2008/wiki3 7 SHOP PAT

From Expertiza_Wiki
Jump to navigation Jump to search

Problem Definition

Shopper pattern. The idea of a "shopping cart" is ubiquitous in e-commerce. This idea lends itself to abstraction in the form of a Shopper pattern. Find examples and descriptions that are suitable for teaching this pattern, if possible, including some non-obvious applications. Write up your findings in the form of a narrative.

Introduction

One of the most popular activities on the Web is shopping. Online shopping carts can provide much more than their offline namesakes, such as making it easy to change the quantity of an item in the cart. It has much allure in it that one can shop at one's leisure at anytime. Customers can compare prices with a click of the mouse and buy the selected product at best prices.The shopping cart is a very well known and international metaphor. The main purpose of Shopper Pattern is to assist the consumer to obtain a collection of items from a set of providers which is achieved by introducing low coupling between the consumer and the provider. This pattern allows users to first collect all the desired products and then pay for them all at once or whenever they want. Consumers can easily search through a large database of products and services and see the actual prices including shipping before they decide to purchase.

Participants

Consider an example where Alice shops a pair of shoes at Amazon. The participants of the pattern is explained in context of the example.

  • Consumer: Provide a list of items required to the shopper. While viewing the description of the product, the consumer is allowed to add the items to their shopping bag. The user is always shown with the current contents in the bag and also the total cost. In this way, the user is always aware of the cost before hand including the shipping charge. From the example, Alice is the consumer who shops a pair of women's shoes online.
  • Shopper: Accepts the shopping list from the consumer and search for the multiple providers for the respective items. Shopper may search the item on different basis eg: Brand name, lowest price, highest price etc according to the consumers choice. Here, Amazon is the shopper who searches for appropriate providers for the items in the list.
  • Provider: It keeps multiple items and make it available to shoppers. At the same time assist the shopper in locating the other providers. Some of the providers for the example are Liz Claiborne, Skechers, Nike etc.
  • ItemRequest: Requested item by the consumer is identified. The ItemRequest here is a pair of women's shoes with price ranging between 50$ to 100$ and of size 10.
  • Item: The things that a provider owns, described by an item request, requested by a consumer, and the shopper obtains. The pair of shoes is the item in the example.

Usage

Used when

  • One or more products are bought by the consumer.
  • One or more instance of a product are bought by the consumer.
  • The consumer wants to shop later.
  • The consumer wants to pay the total amount later.

Implementation

A sequence diagram which illustrates how each objects or processes operate with one another and in what order is given in Figure 1.

Figure 1

A wide variety of application implementations are supported by Shopper pattern. Explanation of the two main key issues to implement the shopper pattern is given below.

  • Traversing the set of providers: Shopper pattern can be used in multiple situations where
    • Providers can be grouped into an aggregate object or arranged in a simple list.
    • Aggregate is known by the consumer and stored in a global variable.
    • When the providers are arranged as arbitrary graph topologyand one or more providers is known by the consumer and stored as a global variable.

A strategy pattern could be applied to handle these variations. It is achieved by configuring a shopper object that traverse along with the strategy object to locate a set of providers. Strategy object may have some idea about some of the providers or else get the details from the consumer. After locating the providers, the shopper (or traversing strategy) provide an iterator to traverse through the set of providers. A provider is able to create a iterator to traverse the providers and also provides a simple interface(like first, next, current, done to the shopper pattern. In case when providers are arranged in a form of linked topology, each provider support a traversing strategy or iterator that would iterate through the adjacent providers. Infinite looping should be taken care of in case of cyclic graphs.It is not necessary that the shopper have to traverse all the provider objects. If the strategy for selecting items at a provider is "first found", it is highly possible that the shopper may quit from further proceeding as soon as all the item request has been satisfied.

  • Obtaining and Selecting requested items at a provider: It is based on couple of basic principles given below.
    • The shopper needs to know about how to obtain the items and should be unaware of what items are provided by a given provider.
    • The provider has the information of what items to provide but should be unaware of what items the shopper needs.

The shopper performs the following actions in order to process the shopping list at a provider.

  1. A provider is asked for the List of items it can provide.
  2. A list is computed which is the intersection of the shopping list and the list of items that the provider can provide.
  3. Items in the intersection list is asked to the provider.

The above mentioned intersection list can be computed in an extremely efficient manner if both the list are bitmapped structures. In addition to it, no additional processor execution time is consumed if the items are optional or not present in any of the providers. Strategy pattern is preferred if same item is found in multiple provider which is achieved by setting a shopper with a selecting strategy object that would know how to select items.

Example of Shopper Pattern: Cloud Computing

In the above example, we considered the case of Alice shopping for a pair of shoes. Another example involving a Shopper pattern and a non physical product is cloud computing. Cloud computing is a computing paradigm in which tasks are assigned to a combination of connections, software and services accessed over a network. This network of servers and connections is collectively known as "the cloud". In this way, users are allowed to access supercomputer-level power. In order to explain the involvement of the pattern, consider an example of a consulting company. A client approaches the company with a project that requires extensive resources say high computing power, 100GB RAM, terabytes of storage that may not be available at the company. It may not be economically feasible and also not worth for a project with a small duration. So the firm resorts to cloud computing to increase capacity or add capabilities on the fly without investing in new infrastructure, training new personnel, or licensing new software. In contrast to a shopping cart example where a physical product is being requested, here services are being requested. There are companies like Amazon Web Services which would take this request and provide resizable compute capacity in the cloud. Amazon would request firms say IBM, Sun etc which will provide these resources. The consulting company could just use the required resources from the Amazon Web Services, and is unaware of the interactions between the Amazon and the providers. So, the consulting company is the consumer, Amazon Web Services is the shopper and SUN is the provider. Thus the concept of Shopper pattern could be used for physical products and non physical services.

Advantages

Some of the advantages of adopting a Shopper pattern are given below.

  • Shopper pattern helps in decoupling the requesting object from the object that provide the requested items.
  • The responsibilities for providing items can be moved between provider objects(at compile or runtime) without affecting the requesting application.
  • The provider objects can be rearranged without modifying the requesting application.
  • Optional items can be optimized in such a way that the processing time will be required only if the item is present in the list.
  • The consumer can browse through many products and add them to their shopping cart without any commitments.

Things to consider

  1. Standard icons and conventions: The icons or a relevant word is a very nice approach to navigatethrough the web sites.The text should be explicit to itself.More than multiple lines of link appears to be two different links. Main links should be attractive and visible that helps user to find easily on the page.
  2. Avoid irrelevant links: On the page of searching for a books there should not be the links of TV,toys etc.In place of that the links related to books should be there.User may need multiple options to search for a book and require multiple option from where he can order the book.
  3. Reveal structure: The structure of searching the items should be attractive and user friendly with multiple options.In the book example the structure should provide the otion where user can search on the basis of multiple option.For ex: search by first name, last name,year etc.providing a toolbar option is very relevant idea where user can navigate the site very easily.
  4. Leave breadcrumbs:The breadcrumb are links that provide the user a higher level way to search if navigation tool does not work.The horizontal series of text links called breadcrumbs are connecting to all parent levels of the hierarchy above the current location. These links also provide the knowledge of the website by placing each page in context within the hierarchy.
  5. Don't bury information: The page on the site should not be farther than three clicks away from any other page. For example.For ex : buy the item, jump to related items, search for another item, purchase items in your shopping cart, and manage your account.
  6. Don't be mysterious: Things on the page should not be hidden.Like when user click somewhere then something pops up and before clicking there was no link or icons to navigate.
  7. Provide help: There should be help on searching the required pages or facility of keyword search.User should have the adjustable search criteria.

See Also

Reference


Back to the Assignment Page