Danny King (kxrs26): Distributed Book Shop System

Report 4 Downloads 19 Views
Danny King (kxrs26): Distributed Book Shop System

Page 1 of 3

03/03/2010

Danny King (kxrs26): Distributed Book Shop System Implementation Details My implementation allows for any number of clients to interact with a book shop server, which in turn interacts with a credit card server. The servers can either be all on one computer or on separate computers on the same subnet. Client queries are sent to the book shop server and if credit card details need to be checked (e.g. if the client requests a book purchase) the book shop server will query the credit card server. This is all hidden from the client, who only needs knowledge of the book shop server and not of the credit card server.

Clients (i.e. customers) can connect to a book shop server and   

search for books or browse all books purchase books view their purchase history

To successfully purchase a book they must enter   

a book ID which exists in the book shop server’s database the quantity of the book to purchase, which must be ≤ the number that is in stock a valid credit card number with enough credit to purchase all the requested books. When a client makes a purchase with a credit card, the credit card server keeps track of how much has been spent so far.

Book shop servers (i.e. administrators) can   

search for books or browse all books add and remove books view purchase records

When a client requests a book purchase, the book shop server will query the credit card server to check the credit card number is valid and has enough credit. If it was valid, a purchase order is automatically added to the book shop server’s database and the stock level of the purchased book is modified by the number bought. After this, the amount of credit left on that card number is decreased on the credit card server by the amount spent. All user input on the command line interfaces of the client and server is checked for errors. If there was an error (e.g. a number was expected but a string was provided) a helpful message will be presented to the user, asking them to try again. Also, if any problems occur (e.g. loss of connection) a message will be presented to the user with suggestions on how to correct it. For your convenience I have programmed the book shop server to automatically add 4 books to its database on initialisation so that you can test the system’s functionality. On top of these, you can add or remove books as you please using the book shop server’s command line interface. Danny King (undergraduate of Computer Science at Durham University) [email protected] www.dannyking.eu

Danny King (kxrs26): Distributed Book Shop System

Page 2 of 3

03/03/2010

Quality of Coding & Implementation  Neat code, well commented.  No redundant or duplicate code.  Code abstracted into separate classes and packages.  The client, book shop server and credit card server are implemented in 3 separate Java projects rather than all in one project, as it would be done in the real world.  Efficient use of data structures and control blocks.  Simple protocol.  The credit card sever keeps track of how much each credit card has been used so that if clients spend more than their maximum credit over time (rather than just in one go) the transaction will be refused. Robustness  Error recovery, exception handling & graceful degradation. Exceptions do not cause the programs to crash, the user may still interact as before.  Useful error messages in cases of failure (e.g. if no hostname is specified to the client).  All user input is validated to ensure erroneous or malicious data causes no damage (e.g. can’t purchase or delete a book that doesn’t exist)  All three applications are stable.  There can be any number of clients communicating with the book shop server, not just one.  The servers can run on three separate computers or all on the same computer.  All 3 projects were compiled using java 1.5 so that they will run on as many computers as possible. Usability and Accessibility To add to the usability and accessibility of the programs:   

A ‘help’ command is included so that the user can check which commands are available. Useful notifications are displayed on both server’s command prompts when important events occur e.g. when a client attempts to purchase a book. If the user provides incorrect input, the program will detail what was wrong with the input.

Danny King (undergraduate of Computer Science at Durham University) [email protected] www.dannyking.eu

Danny King (kxrs26): Distributed Book Shop System

Page 3 of 3

03/03/2010

Installation & Usage Instructions Running order of the three components The credit card server must be running before the bookshop server, which in turn must be running before the client. To run the credit card server, type:

Java –jar CreditCardServer.jar

To run the bookshop card server, type: Java –jar BookShopServer.jar CreditCardServer-IP Where CreditCardServer-IP is the IP address of the running credit card server. To run the client, type: Java –jar Client.jar BookShopServer-IP Where BookShopServer-IP is the IP address of the running bookshop server. You may run as many instances of the client as you like (on a single or on separate computers on a subnet) but you may only run one instance of the bookshop server and credit card server. You may use the command-line interface to interact with the client or book shop server. The following commands are available on the client:      

help - Show this list of commands showbooks - Display all books in the system search - Search for a book (e.g. search database) purchase - Buy a book by ID (e.g. purchase 4) history – Show your purchase history quit - Quit the client

The following commands are available on the book shop server:       

help - Show this list of commands showbooks - Display all books in the system showpurchases - Display all purchase records in the system search - Search for a book (e.g. search database) addbook - Add a book deletebook - Delete a book by ID (e.g. deletebook 4) quit - Quit the server

There is no command-line interface to the credit card server because this functionality is not necessary.

Danny King (undergraduate of Computer Science at Durham University) [email protected] www.dannyking.eu