CSC 307 Lecture Notes Weeks 6 and 7
The Program Design Process
High-Level Design Patterns
GUI Design in Java Swing
Figure 1: The 307 design process.
Figure 2: Design Process Fully Expanded.
"Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use the solution a million times over, without ever doing it the same way twice."
Figure 3: MVP Pattern.
Figure 4: IPT pattern.
Figure 5: Calendar Tool packages.
package caltool.model; import caltool.view.*; import caltool.model.file.*; import caltool.model.edit.*; import caltool.model.schedule.*; import caltool.model.view.*; import caltool.model.admin.*; import caltool.model.options.*; import caltool.model.help.*; import caltool.model.caldb.*; import mvp.Model; /**** * * Class CalendarTool is the top-level model class for the regular-user * Calendar Tool program. CalendarTool has references to the functional model * classes of the tool: File, Edit, Schedule, View, Admin, Options, and Help. * There is also a reference to the CalendarDB class that houses the tool's * major data bases. * <p> * Functionalitywise, all of the model classes are autonomous units. They each * do their own work as invoked by the user. All that this top-level class * does is to construct the work-doing model classes and set up the initial * state of the tool when it is invoked from the outside operating system. * <p> * See also the companion view class <a href= "caltool_ui/CalendarToolUI.html"> * CalendarToolUI. </a> * <p> * @author Gene Fisher (gfisher@calpoly.edu) * @version 13apr15 * */ public class CalendarTool extends Model { /** * Construct this with the given companion view. Call the submodel * constructors. Initialize the start-up state based on default options * and command-line arguments. */ public CalendarTool(CalendarToolUI calToolUI) { /* * Call the parent constructor. */ super(calToolUI); /* * Construct and store the submodel instances. Note that the * CalendarDB is constructed before the File so the latter can observe * the former for changes. */ caldb = new CalendarDB(null); file = new File(null, caldb); edit = new Edit(null); schedule = new Schedule(null, caldb); calView = new View(null, caldb); admin = new Admin(null); options = new Options(null); /* * Set up the initial state of the tool. */ initialize(); } /** * Implement the exit method to pass the buck to file.exit(). Per set up * performed in the companion CalendarToolUI view, this method is called * when the user closes the top-level menubar window, e.g., via the window * manager close button. */ public void exit() { file.exit(); } /** Return the File model. */ public File getFile() { return file; } /** Return the Edit model. */ public Edit getEdit() { return edit; } /** Return the Schedule model. */ public Schedule getSchedule() { return schedule; } /** Return the View model. */ public View getCalView() { return calView; } /** Return the Admin model. */ public Admin getAdmin() { return admin; } /** Return the Options model. */ public Options getOptions() { return options; } /** Return the Help model. */ public Help getHelp() { return help; } /*-* * Protected methods */ /** * Set up the initial state of the tool, based on default option values and * command-line arguments, if any. Details TBD. */ void initialize() {} /*-* * Data fields */ /** File-handling module */ protected File file; /** Basic editing module */ protected Edit edit; /** Scheduling module */ protected Schedule schedule; /** Calendar viewing module */ protected View calView; /** Calendar administration module */ protected Admin admin; /** Tool options module */ protected Options options; /** Tool help module */ protected Help help; /** Calendar database */ protected CalendarDB caldb; }
Figure 6: Class diagram for Calendar Tool design in Notes 2.
users.csc.calpoly.edu:~gfisher/classes/307/examples/milestone4
and is refined into a design specification in theMilestone 4 example
Milestone 6 example
which is further refined and finalized in the 307Milestone 4 requirements
Milestone 6 requirements
Figure 7: Annotated menus showing swing components used.
Figure 8: Annotated dialog showing swing components used.
Figure 9: Annotated dialog showing layout using boxes.
Suffix | Example | Meaning |
UI | ScheduleUI | A top-level view that contains all of the interface components for a companion top-level model. These components are the pulldown command menu and all of the other views that are launched from menu commands. |
Dialog | ScheduleAppointmentDialog | A top-level view that allows the user to provide inputs for a single operation. Typically it has OK, Cancel, and Clear buttons. The OK button is used to confirm the operation for which the user is entering the input. |
Editor | CategoriesEditor | A top-level view that provides for the editing Has more command buttons than just OK, e.g., Add, Delete. |
Display | MonthlyAgendaDisplay | A read-only display, i.e., where no model data are editable. |
ButtonListener | OKScheduleAppointmentButtonListener | An event listener for a button or menu item. |
Panel | SchedulingOptionsPanel | The internal component of a tiled or tabbed layout. |
Table 1: GUI Class Naming Conventions.
Figure 10: High-level Model/View class diagram.
Figure 11: Highest-level function diagram for Model/View application.
Figure 12: Event diagramming notation.
Figure 13: Setting up Calendar Tool event handlers.
Figure 14: Responding to Calendar Tool GUI events.