CSC/ECE 517 Summer 2008/wiki3 7 SHOP PAT
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. Requesting for a pair of women's shoes with price ranging between 50$ to 100$ and the size 10 is the ItemRequest here.
- 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.
Implementation
A sequence diagram which illustrates how each objects or processes operate with one another and in what order is given in 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.
- A provider is asked for the List of items it can provide.
- A list is computed which is the intersection of the shopping list and the list of items that the provider can provide.
- 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.
Cloud Computing:Use of Shopper Pattern
Another example involving a Shopper pattern in 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 Hard disk, terabytes of RAM 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. But, the firm could 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 know and search for firms say Google, 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. As a conclusion, the concept of Shopper pattern could be used for physical and non physical products.
Steps to remember in designing
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Provide help: There should be help on searching the required pages or facility of keyword search.User should have the adjustable search criteria.
Usage
The name Shopper pattern evokes an image of a person wandering from store to store gathering all items.
- Used when one or more products are bought by the consumer.
- Used when one or more instance of a product are bought by the consumer.
- Used when the consumer wants to shop later.
- Used when the consumer wants to pay the total amount later.
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.
See Also
Reference
- Pattern languages of program design 2,Pages:143-154
- DesignSteps
- Shopping Cart
- User Interface Design Pattern Library
- ShoppingCart
- Design Pattern? On-page Shopping Cart Summary
- MetaPatterns: A Pattern Language for Pattern Writing
- How Amazon Works