
Signature _____________________ CSE 70 Name ________________________
Quiz 3
cs70f ____ Fall 2009 Student ID ____________________
This quiz is to be taken by yourself with closed books, closed notes, no electronic devices.
1) General OO Principles
__________________________ what varies.
Favor _____________________________ over _____________________________.
Program to ___________________________, not _______________________________.
Strive for __________________ coupled designs between objects that interact.
2) Design Patterns
____________ pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable.
This pattern lets the algorithm vary independently from clients that use it.
____________ pattern defines a one-to-many dependency between objects so that when one object changes
state, all its dependents are notified and updated automatically.
3)
In the MVC architecture, which part(s) plays the Observable? ________________________________________
In the MVC architecture, which part(s) plays the Observer? ________________________________________
4) Which is usually considered the better design in the Observer Pattern?
A) Push data to the Observer
B) Push data to the Observable
C) Pull data from the Observer
D) Pull data from the Observable
5) In the following Java GUI/Event Handling code fragment:
/* Some GUI control object that lays out GUI components */
JButton button1 = new JButton( "Stop" );
button1.addActionListener( new ResizableBall( /* args */ ) );
public class ResizableBall implements ActionListener
{
/* Lots of other stuff associated with a ResizableBall */
public void actionPerformed( ActionEvent evt )
{
/* Do something with evt */
}
}
Which object is the Observable? _______________________
Which object is the Observer? _______________________