COMP 304B Object-Oriented Software Design -- Assignment 4\\ Due date: Friday April 9, 2003 before 23:55

COMP 304B Object-Oriented Software Design - Assignment 4
  Due date: Friday April 9, 2003 before 23:55

 
[printable version of this document (pdf)] [COMP 304B Home]

Practical information

The assignment

In this assignment you will use UML Class Diagrams, Pseudocode and UML Sequence Diagrams to describe a simple design based on the Command Pattern. The design uses a highly simplified version of part of the DSheet design.
A DSheet has references
SSheetData has a private attribute cellData, a dictionary mapping a given coordinate (a tuple (col,row)) to a SSheetCell object . Its first public method is getCellValue(col,row), which returns the evaluated value of the formula stored at coordinate (col,row). The method setCell(col,row, formulaStr) instantiates and adds to the dictionary a SSheetCell object having formula value formulaStr and coordinates (col,row). A method removeCell(col,row) is also available to remove a given cell (for instance if its formula value becomes empty). It also has a constructor which initializes the datastructures.
Command is an abstract class. Its constructor (used in concrete subclasses) takes a reference to DSheet's SSheetData object as an argument and uses that to provide a local reference named ref. Command declares (and provides dummy, empty implementations) for methods execute() and unexecute().
Command has two concrete subclasses, DisplayCommand and SetCommand.
DisplayCommand's execute() method uses the ref reference to loop over all cells and print their values to the screen. DisplayCommand does not override the default, dummy unexecute() method in Command (as DisplayCommand's execute() method does not modify the state of the subject).
SetCommand has an askUser() method which prompts the user for row, column, and formula to set. It returns the tuple (row, column, formula). SetCommand's execute() method calls askUser() and subsequently uses the ref reference to set the appropriate cell to the value given by the user.
SetCommand has a memory attribute as it is necessary to remember the effects of execute(). Using this memory information, unexecute() will be able to undo previous execute()s. Note how you must support an arbitrary number of undo levels.
Your assignment solution should contain:
  1. A Class Diagram depicting all relevant classes, their attributes and methods, as well as all relationships between the classes.
    Pseudocode (in sticky notes) must be provided for all important methods (in particular, for execute() and unexecute()).

  2. Pseudocode for a Use Case in which
    1. a DSheet object gets created;

    2. this also creates a SSheetData object;

    3. two Command objects get created, one DisplayCommand and one SetCellCommand object. They get stored in the first and second position of the DSheet's cmds list;

    4. the execute() method of the DSheet's first command (in its cmds list) gets called;

    5. the execute() method of the DSheet's second command (in its cmds list) gets called. Assume the user decides to set the cell at row 5 and column 5 to 5;

    6. the execute() method of the DSheet's first command (in its cmds list) gets called;

    7. the execute() method of the DSheet's second command (in its cmds list) gets called. Assume the user decides to set the cell at row 5 and column 5 to 10;

    8. the execute() method of the DSheet's second command (in its cmds list) gets called. Assume the user decides to set the cell at row 1 and column 1 to 1;

    9. the unexecute() method of the DSheet's second command (in its cmds list) gets called.

    10. the execute() method of the DSheet's first command (in its cmds list) gets called;

    11. the unexecute() method of the DSheet's second command (in its cmds list) gets called.

    12. the execute() method of the DSheet's first command (in its cmds list) gets called;

    For each operation, describe the new state of the relevant objects.

  3. A Sequence Diagram depicting the above Use Case.

The Class Diagram, Pseudocode, and Sequence Diagram must be consistent.
Add short explanations where necessary.



File translated from TEX by TTH, version 3.40.
On 1 Apr 2004, 22:31.