- Forward


Discussion of Programming Assignment 1


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

CellConverter
Back SMYC Forward
edu/jmu/cs/academics/bigpixel/gui/CellConverter.java
 
CellID
Back SMYC Forward
edu/jmu/cs/academics/bigpixel/gui/CellID.java
 
ColorFactory
Back SMYC Forward
edu/jmu/cs/academics/bigpixel/gui/ColorFactory.java
 
GridComponent
Back SMYC Forward
edu/jmu/cs/academics/bigpixel/gui/GridComponent.java
 
GridConverter
Back SMYC Forward
edu/jmu/cs/academics/bigpixel/gui/GridConverter.java
 
InvalidCoordinateException
Back SMYC Forward
edu/jmu/cs/academics/bigpixel/gui/InvalidCoordinateException.java
 
Utility Classes, "Ordinary" Classes, and Singletons
Back SMYC Forward

The ColorFactory class is a utility class. It could, instead, be an ordinary class or a singleton. What are the tradeoffs? What is one of the important deciding factors?

Visibility of Attributes
Back SMYC Forward

The Rectangle2D.Double has public attributes while the CellID class has private attributes and getters/setters. What are the tradeoffs? Does making the attributes final change the tradeoffs?

Exceptions vs. Special Return Values
Back SMYC Forward

In this case, all of the methods that throw exceptions could, instead, return null when there is a problem. What are the tradeoffs?

Are the tradeoffs the same for both checked (e.g., InvalidCoordinateException and unchecked (e.g., RunttimeException) exceptions?

"Custom" Exceptions
Back SMYC Forward

Is there a reason to include the InvalidCoordinateException in the design? Could we use an existing exception (e.g., Exception if it needs to be checked or IllegalArgumentException if it needs to be unchecked)? Does the decision to add an exception class depend on whether it needs to be checked or unchecked?

"Global Variables"
Back SMYC Forward

The GridComponent class constructs a large number of Rectangle2D.Double objects in its paint() method. How might you use "global variables" to reduce the amount of object creation? What would need to change in the GridConverter class? What are the tradeoffs?

Assertions
Back SMYC Forward

The paint() method use assertions when they could either do nothing or throw the exception. What are the tradeoffs?

Parameterized Classes
Back SMYC Forward

The CellID and CellConverter classes are parameterized (specifically, the types of the columns and rows). What are the advantages?

What changes would need to be made to the specialization of JComponent to take advantage of this?

Is the current design the best way to provide this flexibility?
(An Alternative Design)

Ordinal
Back SMYC Forward
Ordinal.java
 
OrdinalFactory
Back SMYC Forward
OrdinalFactory.java
 
IntegerCounter
Back SMYC Forward
IntegerCounter.java
 
IntegerCounterFactory
Back SMYC Forward
IntegerCounterFactory.java
 
DisplayComponent
Back SMYC Forward
DisplayComponent.java
 
There's Always More to Learn
Back -