150 likes | 209 Views
SIMPLE PROBLEM SOLVING in Java: a Problem Set Framework Viera K. Proulx Richard Rasala Jason Jay Rodrigues http://www.ccs.neu.edu/jpt CCSCNE 2002 Conference Worcester State College, Worcester, MA April, 19, 2002. Outline. Motivation Goals JPT background The Problem Set Framework
E N D
SIMPLE PROBLEM SOLVING in Java:a Problem Set FrameworkViera K. ProulxRichard RasalaJason Jay Rodrigueshttp://www.ccs.neu.edu/jptCCSCNE 2002 Conference Worcester State College, Worcester, MAApril, 19, 2002
Outline • Motivation • Goals • JPT background • The Problem Set Framework • The architecture • Uses of PSF • This is all you need to know Proulx, Rasala, Rodrigues
Motivation We wanted to be able to • write small functions – without classes • explore classes • constructors, member functions • copy vs. assignment vs. clone • test classes as they are built • run several different applications easily Proulx, Rasala, Rodrigues
Goals Create a framework that would give us • access to the console • access to the graphics window • one action button per function we want to test • automatic action button definition and labeling • synchronization of the button responses • ability to add other classes to the project Proulx, Rasala, Rodrigues
JPT Background Toolkit to support fast GUI building in Java Support for Model – View communication Support for Action – Control binding Support for robust input stream parsing Support for graphics Support for layout control Support for event – action – adapters Platform for showcase labs Proulx, Rasala, Rodrigues
JPT Background Actions – installed in one statement Console • parsed error-checked input • color coded input, output, error stream • scrollable, can save to a file, resize font Graphics – buffered panel with mouse action adapter GUI components, layout control, more... Proulx, Rasala, Rodrigues
The Problem Set Framework • Two classes – application and framework • Application builds GUI, buttons, console • Framework contains user’s test functions • Mutual reference – allows two-way access • The test functions access the graphics window and console supplied by the application • The GUI buttons created by the application use the code in the test functions for their actions Proulx, Rasala, Rodrigues
The Problem Set Framework • Each test function runs in its own thread: ThreadedAction class defined • All functions synchronized • Use reflection to • extract function names • create button labels • define corresponding actions • Catch the exception messages – forward to the user Proulx, Rasala, Rodrigues
The Architecture and Design User side: ProblemSetClass • Modify the ProblemSetClass • define the test functions using the pattern public synchronized void TestFunction(){...} • define additional utility functions – if you wish • define objects that all test functions can share – if you wish • use text I/O – via System or (JPT) console • use graphics (Java2D Graphics) – in the BufferedPanel • Add any classes that you want to test to the project • UseGeneralDialog for additional interactions Proulx, Rasala, Rodrigues
The Architecture and Design System side: ProblemSetApplication • define and install the BufferedPanel in the main frame and activate the (JPT) console • use reflection to get a list of all methods that are declared as: public synchronized void TestFunction(); • create a ThreadedAction and button for each • use method names for button labels • add the Clear Window button and the Exit button Proulx, Rasala, Rodrigues
Uses of PSF • Simple algorithmics and problem sets • Tutorials on OO concepts • constructors and the reference model • inheritance • abstract classes • static • interfaces • casting • Data structure exercises – with display Proulx, Rasala, Rodrigues
Uses of PSF • In lecture demonstrations and live exploration of new concepts • Unit testing for a new class or classes • to be used both by students and developers • Demo platform • several different applications may be grouped in one PSF and launched without the need for separate projects or separate compilations Proulx, Rasala, Rodrigues
This Is All You Need To Know • Project includes two classes and jpt.jar • Modify only the file ProblemSetClass.java • Insert functions to run – make sure that the method header has the form public synchronized void TestFunction( ){...} • Add utility functions using a different header • Add additional classes as needed • Compile and run the PSF application Proulx, Rasala, Rodrigues
This Is All You Need To Know We cannot and do not want to live without it • We use the PSF in nearly every lecture • Students run regression tests on their work • Tutorial examples on classes and objects are given to students in PSF format • We use the PSF test bed to develop new JPT features Proulx, Rasala, Rodrigues
SIMPLE PROBLEM SOLVING in Java:a Problem Set FrameworkViera K. Proulx vkp@ccs.neu.eduRichard Rasala rasala@ccs.neu.eduJason Jay Rodrigues jjayr@ccs.neu.eduhttp://www.ccs.neu.edu/jptPartially supported by the NSF grant DUE-9950829