150 likes | 171 Views
Proven solutions to commonly occurring problems, encourage good designs, capture reusable experience, provide insights into the Java API.
E N D
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.
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.
Using the Extension Information about the design pattern. Choose pattern to adopt. Image of pattern in BlueJ.
Using the Extension Rename component option. Information about individual components role in the pattern.
Inspecting the Pattern in BlueJ Operation method of the DarkRoast object Result of DarkRoast operation displayed in terminal
Inspecting the Pattern in BlueJ Operation of the MilkDecorator object Inspection of the MilkDecorator object New MilkDecorator object created with the DarkRoast object Result of operation now shows added behaviour, as well as original. Inspection shows that the MilkDecorator has an attribute that it Decorates.
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
Pattern description <?xml version="1.0"?> <pattern patternName="Decorator" patternImage="decorator.bmp"> <patternDescription> <![CDATA[ Description of decorator pattern]]> </patternDescription> ...
Pattern components <class classId="3" compType="Decorator" defaultName="Decorator" classDescription=”Description” classTemplate="Decorator/Decorator.TMPL"> <dependantClass value="1"/> </class> ...
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>
Class template public class $CLASSNAME implements $DEPENDANT1 { protected $DEPENDANT1 component; public $CLASSNAME($DEPENDANT1 component) { this.component = component; } ...
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