|
Discussion of Programming Assignment 1
|
|
Prof. David Bernstein
|
| Computer Science Department |
| bernstdh@jmu.edu |
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?
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?
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?
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?
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?
The paint() method use assertions when they could
either do nothing or throw the exception. What are the tradeoffs?
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)