Feb 1 at 17:30. There will be no late assignments accepted.
4% of your final mark
This assignment builds experience in writing applets using AWT 1.1. You will learn how to use the Model-View-Controller method of structuring interactive applications, and understand some facets of what constitutes good OO decomposition for UI design. Students unfamiliar with basics of Java will also benefit from reading other code and developing their own code.
I recommend doing Exercises 1 and 8 on your own.
Observable
s.
As per usual for assignment, document all code with javadoc
comments, but do not hand in generated .html. Emphasis should be paid to
clearly explaining your code and its structure.
Button
and Label
.
Note that TempModel
and TempController
are
not completely separated in ThermometerMVC318.java
since
TempController
needs
to know how to set the temperature.
TempController
uses an anonymous
inner class to set the model's temperature through its
tempModel
reference. It is possible to remove
the need for tempModel
in the code for
TempController
by putting all direct
references to tempModel
only within subclasses
of TempController
. That way only subclasses need
to know about TempModel
.
Modify the
ThermometerMVC318
applet so that TempController
is separated from TempModel
through subclassing.
Keep the myButton.addActionListener() ( new ActionListener() ... );
call within TempController.
(Hint: you may need an abstract method in TempController
).
(Hint #2: you may wish to use inner classes when subclassing TempController
)
(3 marks)
TempModel
from TempController
.
In the original TheremometerMVC318
and your
variant in part (a), there is always a direct reference to
a TempModel
object within the TempController
hierarchy. Thus setting the temperature is never delegated to
another object.
Modify the TempController
of ThermometerMVC318
so that it delegates the temperature modification action to
another object. Aftwards, neither TempController
nor
any of its subclasses should be setting the temperature directly.
(Hint: Your delegate object could implement the
ActionListener
interface to respond to change requests.)
Compare this second method of separation to part (a). Why might one chose one separation method over the other?
(4 marks)
What effect do the changes you made in part (a) and (b) have
on this separation? Briefly explain.
(1 mark)
(These issues are discussed in Eckel's coding recommendations (starting pg. 675), and in the other two readings).
Internet search engines are required navigation facilities for the WWW. Search engines are database systems that collect and store information about web pages available on the Internet, or within intranets. There are literally dozens of search engines available for free use.
As we discussed in class, the search engines are clearly indispensible, but there are several drawbacks to how they are currently implemented. One of the main ones is the way they are accessed. As is typical for a database they are accessed through a query language in which the user can specify the type of information they are looking for. The result of the queries is normally a sequence of links to web pages with their titles and descriptions.
Unfortunately, the standard query mechanism for these databases is almost universally through standard HTML. Queries are entered into a simple text box in a form, and results are returned as a sequence of marked-up HTML pages. In this form the query results are difficult to navigate, manipulate, and work with. The underlying problem is that query results are data, but the results returned by the server is a display of this data in a fixed (and chunked up) form. As a result, the user cannot quickly switch the form of the display, and needs to potentially navigate many web pages to see the results. This can be slow. Moreover further query restrictions require a new search. Besides, most search engines include annoying banners and advertising that many users would prefer not see. You are to build a better (but simple) search engine-result browsing applet as follows:
[search]
button, and then waiting for the result set to come back.
In order to be compatible with most browsers, you must write your
UI with AWT 1.1 components using the delegation-based AWT 1.1 event
model.
This should not stop you from completing the assignment.
You can use appletviewer to test out the querying, but you won't be
able to browse the documents since appletviewer is not a full-fledged
browser. Instead of loading the selected
target URL, simulate browser action by displaying just the
body (Hit.body
) of the selected document on the applet window.
Notes: