Last Time: Boundary Object Responsibilities
Last Time: Boundary Object Responsibilities
or...
<<boundary>> <<control>>
StaffUI BookingSystem
Possibilities
StaffUI
violates
<<depends>>
BookingSystem
Presenting the application data to the user
how is the boundary class informed that the application data has
changed?
an aside …
Design patterns
They are available in the literature and are covered in far more detail in
CSE3OAD [Object-Oriented Application Development]
In our case there is one subscriber object (StaffUI) and one publisher
object (BookingSystem). The state changes are changes in the
application data e.g. currently selected booking, the set of current
booking etc.
Presenting the application data to the user
The Observer (Publish-Subscribe) design pattern can be described as
follows (from Larman p. 373)
Solution
"An Interface is a specialised class declaration that can declare constants and
method declarations, but not method implementations". (Java API)
In UML
<<implements>>
SampleClass InterfaceClass
… a realisation
Presenting the application data to the user
Another aside … Interface Classes
"An Interface is a specialised class declaration that can declare constants and
method declarations, but not method implementations". (Java API)
In Java
<<implements>>
BookingSystem <<interface>>
BookingObserver
*
Presenting the application data to the user
So how does it work in the Restaurant system ?
This is
implemented
When the system data <<implements>> by the StaffUI
changes (e.g the current object.
bookings have changed), the
BookingSystem notifies the BookingSystem <<interface>>
BookingObserver
appropriate BookingObserver addObserver()
notfiyObserver() update()
through notifyObserver(), displayBookings() *
}
Presenting the application data to the user
Now for a simple demonstration (in Java)
… and finally the interface class, BookingObserver
Here is the main …
import java.util.*;
import javax.swing.*;
public interface BookingObserver
import java.awt.*;
public class InterfacePractice1
{
{
public static void main(String[] args)
{
public void update();
EventQueue.invokeLater(new Runnable()
{
public void run()
}
{
StaffUI StaffInterface = new StaffUI();
}
} ); // end of invoke trying to ensure that the events and apps are in
the same thread
} // main
} // class
Next time …