Pattern Support for BlueJ

Download Report

Transcript Pattern Support for BlueJ

Design Pattern Support
for BlueJ
Michael Nairn (Bell)
Jim Paterson (GCU)
John Haddow (Bell)
Design Patterns
•
Proven solutions to commonly occurring problems.
•
Encourage good designs.
•
Capture experience which can be reused by others.
•
Provide insights into the Java API.
http://hamilton.bell.ac.uk/designpatterns/
Design Patterns Extension for BlueJ
•
Encapsulate knowledge of design patterns.
•
Allow the selection of different design patterns
•
Allow interaction during the creation of the pattern.
•
Add the pattern to the current project.
•
Allow students to solve problems using design patterns.
•
Expandable, allowing the addition and modification of pattern files.
http://hamilton.bell.ac.uk/designpatterns/
Using the Extension
Information about
the design
pattern.
Choose pattern to
adopt.
Image of pattern
in BlueJ.
http://hamilton.bell.ac.uk/designpatterns/
Using the Extension
Rename
component
option.
Information about
individual
components role
in the pattern.
http://hamilton.bell.ac.uk/designpatterns/
Using the Extension
http://hamilton.bell.ac.uk/designpatterns/
Inspecting the Pattern in BlueJ
Operation method of the DarkRoast object
Result of DarkRoast operation displayed in terminal
http://hamilton.bell.ac.uk/designpatterns/
Inspecting the Pattern in BlueJ
Operation of
Inspection
of the
the MilkDecorator
MilkDecorator object
object
New MilkDecorator object created with the
DarkRoast object
Result
Inspection
of operation
shows that
nowthe
shows
MilkDecorator
added behaviour,
has an
attribute
as well
that
asitoriginal.
Decorates.
http://hamilton.bell.ac.uk/designpatterns/
Modification of a problem
http://hamilton.bell.ac.uk/designpatterns/
Creating your own patterns
•
Patterns defined as XML files and class templates
•
Each pattern described by one XML file with three main sections:
– Basic pattern description
– Pattern components
– Wizard steps
•
Each component class is based on a template with placeholders for names
of the class and dependants
http://hamilton.bell.ac.uk/designpatterns/
Pattern description
<?xml version="1.0"?>
<pattern patternName="Decorator"
patternImage="decorator.bmp">
<patternDescription>
<![CDATA[ Description of decorator
pattern]]>
</patternDescription>
...
http://hamilton.bell.ac.uk/designpatterns/
Pattern components
<class classId="3" compType="Decorator"
defaultName="Decorator"
classDescription=”Description”
classTemplate="Decorator/Decorator.TMPL">
<dependantClass value="1"/>
</class>
...
http://hamilton.bell.ac.uk/designpatterns/
Wizard steps
<wizard>
<step stepId="1" type="class" compId="1"
nextStepId="2" previousStepId=""
stepName="Rename Component"
stepDesc="Use the text field to enter a
relevant name for the Component
class.">
</step>
...
</wizard>
http://hamilton.bell.ac.uk/designpatterns/
Class template
public class $CLASSNAME implements $DEPENDANT1
{
protected $DEPENDANT1 component;
public $CLASSNAME($DEPENDANT1 component)
{
this.component = component;
}
...
http://hamilton.bell.ac.uk/designpatterns/
Please try it out
Extension, source and documentation can be found at:
http://hamilton.bell.ac.uk/designpatterns/
This project has been supported by the Bell College Research Grants Fund
http://hamilton.bell.ac.uk/designpatterns/