View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Reuse

Reuse
The StockTicker UI is almost completely reused from the Newspaper UI. The Newspaper UI was made in a generic manner. During initialization, an AlignmentMorph is created which will hold all the buttons in the south region of the UI. This AlignmentMorph is added to the main window as a submorph, and is placed in the south. Whenever a button is added to the UI, it is added by calling a generic "addButton: anAction:" method. This method is shown below:
   addButton: aLabel action: anAction
      "Adds a button to the alignment morph with the given action"
      | newButton |
      newButton := PluggableButtonMorph on: self getState: nil action: anAction.
      newButton label: aLabel.
      newButton onColor: Color green offColor: Color green.
      newButton cornerStyle: #square.
      newButton borderColor: Color blue.
      newButton feedbackColor: Color blue.
      buttonAlignmentMorph addMorph: newButton.

Thus, the south region of the UI is divided equally into however many buttons you add to the region. This generic method made creating new and different UIs extremely easy. Instead of creating a "Generate Newspaper" button, we created an "Update Stocks" button.

The stocks were displayed in a PluggableListMorph, just as our Newspaper categories had been displayed.

After meeting the requirements, we decided to spice-up the lab a little. We made our StockTicker a Model, and created a step method. Then, we added a GraphMorph to show each stock's personal history. We converted the "Update Stocks" button to merely a "Start Tracking Stocks" button. Because the UI was created in a generic manner, these changes were easily made.

In addition, we were about to reuse our FileReader class. Since the stock information was pulled from a regular HTML page, the code we had to get that information and parse it was the same as what was needed for the newspaper.

Link to this Page