Assignment 6: Beyond gOOD:   A Simple Spreadsheet, Part 2
1 Views
1.1 View interface(s)
1.2 A textual view:   Saving files
1.3 Visual Spreadsheet view
1.3.1 General requirements
1.3.2 Implementation Details
1.3.3 Custom scroll-pane hints
2 What to do
3 Running and Testing
3.1 Testing
3.2 Creating a JAR file
4 Submission
5 Grading standards
7.5

Assignment 6: Beyond gOOD: A Simple Spreadsheet, Part 2

Due: Thu 11/14 at 8:59pm; self-evaluation due Fri 11/15 at 9:59pm

You are to complete this project with the same partners as on Assignment 5.

In this assignment will implement several views for your model from the last assignment. A view is responsible for rendering (some or all of) the data in a model in a form that is understandable to whoever is actually trying to use the data.

1 Views

In this assignment you will work on two views for your spreadsheet application.

As with the model, in the abstract sense, a view is an interface; particular concrete views implement that interface. Accordingly, your work in this assignment should carefully distinguish between any one particular implementation of a view and the common interface to which they should all adhere. Moreover, if your model from Assignment 5 failed to have a similar interface/implementation split, you must fix that.

1.1 View interface(s)

Start by planning your views, and observing which operations you need. Although different views look and behave differently, there are some common aspects to all views. The design of the actual interface(s) is left up to you. A common design technique is to have a view interface that has methods for all plausible functionalities and then individual view implementations suppress or provide defaults for functionalities they do not implement (e.g. Fundies 2 uses this technique to motivate double dispatch: you can review it here.). Another relevant, and contradictory, design rule is from the SOLID principles from Lecture 1: Why object-oriented design?: Interface Segregation (No client should be forced to depend on methods that it does not use). These two ideas are in direct conflict; think about them carefully as you come up with a design for your views, and justify whatever design you come up with.

1.2 A textual view: Saving files

One natural task for any spreadsheet editor is the ability to save your work. Design a view implementation that takes a model and an Appendable, and renders the model into the Appendable in the same format as you read files in Assignment 5. You might find the PrintWriter class to be a convenient Appendable for actually writing files to disk. Your output does not have to reproduce any comments or specific formatting that was in the original file, and does not have to print the cells back in the same order that they were in the original file. One useful test case might be to read in a file, render it through this view, and then read this view’s output back in as a second model, and check that the two models are equivalent. (This is sort of a “round-trip test”, and is a very common pattern for testing file reading and writing.)

1.3 Visual Spreadsheet view

In this view you will render the spreadsheet inside a window, drawing a grid of cells and showing their values.

1.3.1 General requirements
1.3.2 Implementation Details

To implement this view, you will need to use Java Swing. (You are not permitted to use the javalib library we used in Fundies 2, as it conflates the notions of model, view and controller into a single World class. Additionally, Java’s other GUI library, JavaFX, is overly complicated for our purposes.) The code provided with the MVC code and the Turtles activity from class give you a basic beginning using Swing. Some hints:

1.3.3 Custom scroll-pane hints

First, consider if you even need a custom scroll-pane, or if JScrollPane works for your needs. (What operations might a user of your view eventually want to perform, and can your view—and eventually your controller—support them?) If you can make a standard JScrollPane work for you, great! If you attempt to build your own scroll panel, you’ll need to design at least two classes:

2 What to do

  1. Implement the textual view above. Place all the code of your views in the edu.cs3500.spreadsheets.view package.

  2. Implement the visual view above, at first without getting scrolling to work. Again place all the code of your view in the edu.cs3500.spreadsheets.view package.

  3. Get scrolling to work in your visual view.

  4. Document any further changes made to your models from the previous assignment: explain what was added, removed or changed, and why.

  5. Enhance your main() method to run your new views, as described in the next section.

  6. Create a JAR file of your program (also described below).

3 Running and Testing

You already have a main method from Assignment 5. However, its command-line argument handling only implements a single behavior so far, of evaluating and printing a single cell. You must enhance your your command-line handling to support four command-line styles:

3.1 Testing

You should be able to test your text-based view thoroughly, but you may have difficulty testing the visual view.

Unit-testing the visual view is optional. Unit-testing the other view is not.

3.2 Creating a JAR file

A JAR (Java ARchive) file is the self-contained executable form of a Java program. To create a JAR file, do the following:

4 Submission

5 Grading standards

For this assignment, you will be graded on

Please submit your homework to https://handins.ccs.neu.edu/ by the above deadline. Then be sure to complete your self evaluation by the second deadline.

1This is unfortunate, but it is very common in Swing programming and there’s no good way to avoid it.