CS 204: Software Design

Stock Markets and the MVC pattern

Of all the patterns in our Design Patterns book, the one I run into most often in my day-to-day programming life is the Model, View, Controller (MVC). In this assignment, you will implement a simple example of the MVC architecture to display stock market data using Java's GUI library.

Your program from the user's perspective.

When your program starts up, it will start collecting stock market index data from whichever stock market web sites you choose to use for your data sources. You should collect data on at least three stock market indices. You may also choose to collect data on individual stocks, if you wish. Depending on what time of day you expect to be working on the program, you may want to choose some Asian market indices to help you test, since they'll be open during the Minnesota night. In any case, make sure to collect data from web sites that update frequently (ideally once per minute or more often).

Your program should display, in a reasonably compact window:

Architecture

Design your program with a version of the MVC pattern in mind. As we have discussed in class, sometimes the V and C get fused into a single class, so you may wish to use an architecture like that. In any case, make sure to separate the models (e.g. the classes storing each stock market index) from the views (the current-value view and the line-graph views).

What to hand in

Hand in source code and a readme. The readme should explain your class design, your command-line syntax, and the status of your program.

Notes and suggestions

We will be doing another round of code reviews with this program, but not a rewrite.

One of the main goals of your design should be ease of extensibility. For example, if somebody were to ask you to add a new stock index data source to the program, how hard would it be to do so? Similarly, if you wanted to add interest rates or hog futures to the display, how hard would that be?

I strongly urge you to spend a lot of time up-front developing a design for your program. What classes do you need, and how many instances of each? What responsibilities will these classes have? Is inheritance an appropriate tool, or should you be using composition or interfaces? Where?

While you are working carefully on your design, you can also do some prototyping and bottom-up kinds of coding. For example, you will need to figure out how to use timers, and how to get the source for a given web page, and how to draw lines and text in a window. You will also need to parse the HTML results you retrieve from the various web sites, so an exploration of Java's text-parsing and regular expression support is in order. These are problems that you can work on in small experimental programs before your overall design is ready, because you know you will need to solve them eventually.

Here's a small gift for you--a simple Java program that retrieves a web file. (Here's something similar for Python, but you won't need it for this assignment, since you'll be writing in Java.)

Start early (really!), have fun, and keep in touch.