Due date: at class., Tuesday, April 8th.
This assignment is pledged. You may work in teams of three or smaller.
You are to design the first version of an application that lets a user keep track of the values of stocks and portfolios of stocks that the user owns. Your system interacts with a Ticker, which is a source of stock price data that is external to your system. (Your system will have a proxy object from which objects you design will retrieve stock price data. You'll be given its specifications.)
The user will be able to look at several possible views that the system can display:
Portfolio View:
This will display the name of the portfolio, and a list of stock holdings. Each holding displays the stock's ticker
symbol, the quantity owned, the original purchase price, the current price, the total value of the holding in that
stock, and finally the gain or loss since purchase. The portfolio name is given by the user when the portfolio
is created. An operation for adding a stock-purchase to the portfolio will exist in which the user supplies the
ticker symbol, the quantity, and the purchase price. The current price at any given moment is obtained from the
Ticker, and the other values can be thus calculated.
Watch List View:
The system supports one Watch List, which is simply a list of stocks that the user is interested in following (but
may not own). The Watch List View displays these stocks by showing their ticker symbol and current price (from
the Ticker).
Stock View:
The system allows the user to display a detailed view of a single stock. This view displays the stock's name and
ticker symbol, the current price, and the high and low price. (To keep things simple for now, these last two will
be the highest and lowest price ever seen.)
The goal of the assignment is to use UML class diagrams and sequence diagrams to create a design for a fairly simple first iteration of such a system. Another goal is to learn the Observer pattern and see it in use.
It is not the goal of this assignment to learn the details of a GUI library like Java's Swing or C++'s MFC. Thus your design may not be complete enough to create a running application, but you should be able to add a user-interface layer on top of the classes we create here to actually make this run. (This might be a later Java assignment.)
Thus for this homework you'll create UML diagrams and answer some questions that will help you create good diagrams.
A analysis level class diagram might look like this:
Some use cases:
Preliminary Design:
Assume there is a main window or GUI menu system from which a user can:
This object and these operations are not shown in the diagram that follows. What this does show is a partial, incomplete start to the design-level class diagram.
In this design, a StockManager object (a singleton) keeps a list (or map or whatever container class you wish) of all the Stocks that are currently present in any view the program has. The StockManager object periodically sends a query to the Ticker to retrieve the current value for each Stock it knows about.
Problem domain (PD) objects (e.g. WatchList) are linked one-to-one with a GUI object (e.g. WatchListView). For
this exercise, this is mostly a way to decouple GUI-specific traits from the design exercise. But the system could
really be built this way. Assume that the View object knows its PD partner and invokes operations in the PD object.
For example, there may be an AddNewHolding() operation in Portfolio object that gets invoked by the PortfolioView
object. The GUI and implementation
details are in the View object, not in the PD object. If you need to draw a sequence diagram, the left-hand side
would usually start with a view object invoking an operation in the PD object. Note: We will assume that all views
are obervers of their partner PD objects; thus, each View class has an update() operation that may be called by
the PD object when it believes its view needs updating.
You will turn in a more detailed design-level class diagram. In addition, answer the following questions. Some involve creating other UML diagrams. Answering these questions may also help you create your class diagram too. Your class diagram should have the classes, operations and attributes to support your answers below.
In your design-level class diagram, show as many operations and attributes as you think are required. You must show all of these that are needed to understand your UML sequence diagrams drawn for Questions 1 and 6 above. Also, show the complete set of associations that you believe are necessary. You do not have to make any hard decisions about implementation of associations or container classes for this exercise; we'll just know they'll be there eventually because of the aggregation and association in the diagram.
Where you need to use the Observer design pattern in your design, here are some things to do in your class diagram. First, let's not have a Multicaster object in the system. Instead, we'll assume each Observable contains the operations needed. Second, you must choose between the Java-style implementation of this design pattern, or the version proposed by Coad (and documented in the lecture slides). Note that your choice will affect what you show in Question 6 above.
See the note in Question 7 above about not showing inheritance or interfaces in your class. I hope this makes things easier for you. If not, let me know and we can negotiate!