Java Reference
In-Depth Information
import java.util.*;
class SampleClass {
private ArrayList names # new Arraylist();
public SampleClass(){
names.add( new String("James"));
names.add( new String("Maria"));
public void printNames(){
Iterator iterator # names.iterator();
while (iterator.hasNext()) {
String name # (String);
Force resolution
The visiting algorithms access the component objects through a standard
interface. The implementation of concrete container classes and of specific
visiting algorithms can vary independently.
Design rationale
This architectural solution keeps the method for creating the collection
separate from the method for visiting the collection. Several iterator objects
can visit the same collection simultaneously and independently.
Pattern type
Model - view - controller
The system architecture of a graphical user interface.
Often a GUI offers multiple views of the same data. Application data could
be displayed as a table, as a graph, as a chart, etc.
Forces or tradeoffs
The user must be allowed to choose how to display the application data,
i.e. how many and which views must be active simultaneously for the
same data. The user must be allowed to input data in a view and see the
updated values in all the other views.
The architecture of the graphical interface should separate the objects
that hold the application data (the model) from the objects that present
these data to the user (the views).
The user inputs data using the standard I O devices, i.e. the mouse and
the keyboard. The objects that listen to the input events (the controller)
should be kept separated from the model and the views. The controller
has the responsibility to update the model with the input data and to
refresh all the views. The resulting architecture is structured as in the
following diagram.
Search WWH ::

Custom Search