Week 5: Frameworks and Pattern Introduction Flashcards
Learning about Frameworks and design patterns through JHotDraw.
What is a framework?
A reusable skeleton of an application that can be customised and used by a developer to be the backbone for different applications.
What are the two types of Frameworks?
Black box and White box.
What is a black box framework?
A framework where it is parameterised and the application using it has little to no interaction with the actual framework source code.
These are designed with end users in mind.
What is a white box framework?
A framework that is reusable as the design of all or part of a system that is represented as a set of abstract classes and the way their instance interact.
What is a white box framework?
A framework that is reusable as the design of all or part of a system that is represented as a set of abstract classes and the way their instance interact.
What is the JHotDraw framework?
A framework for creating ‘semantic’ drawing editors. It provides tools for creating shapes, drawings, constrained connections between objects on screen and limited animation
What is the typical kind of program that might use the JHotDraw framework?
A UML diagram creation program.
What kind of architecture design does JHotDraw follow?
Model View Controller (MVC)
Explain the class that represents the Model in JHotDraw.
The drawing class It's a container for the figure models. It listens for any figure changes on the View and updates the data. This is done via the observer design pattern.
Explain the class that represents the View in JHotDraw.
The DrawingView class.
It is responsible for creating and displaying the GUI. It makes use of the observer design pattern.
Explain the class that represents the Controller in JHotDraw.
The DrawingEditor class.
New applications that want to use JHotDraw should extend this controller. It is the backbone of JHD, including all its core functionality. It makes use of the factory method design pattern.
Explain the Figure class in JHotDraw.
It is a key class/interface of the framework. Every model that can be manipulated and drawn within JHD inherits from Figure, whether directly or indirectly.
Figures can be drawn/manipulated within the rectualer DisplayBox in the View.
Name and explain three things in JHotDraw that are associated with and can manipulate figures.
- Handles - can be used to effect the properties of figures e.g. Stretch, move, resize etc.
- Connectors - used to join figures together by their connection points (Connection points are points on figures that can be used to connect to other figures via a line or arrow etc.)
- Locators - used to locate points on a figure to position the handles (e.g. North East corner point)
What design pattern do both connectors and locators use?
Strategy design pattern.
What is the Painter in JHotDraw?
An algorithm used for drawing on screen.
It uses the strategy design pattern.
What are the Tools in JHotDraw?
It’s a panel that goes down the left hand side. It shows all the tools that can be used in the application. New applications can create their own tools for JHotDraw. Creating new tools uses the prototype design pattern.
What design pattern is used when switching between tools in JHotDraw?
The state design pattern.
Explain the Command in terms of JHotDraw.
It is used to encapsulate an action to be executed. It uses the command design pattern.
Explain what PointConstrainer does in JHotDraw.
It is used to contrain points in the application view, like snapping figures to a grid layout.
What is LineConnection in JHotDraw?
The on screen visual connection between figures. Normally resented by a line. It implements ConnectionFigure and is classed as a figure model itself. It uses the observer design pattern to listen for changes in the figures it is connected to.
What makes Frameworks so flexible and reusable?
The use of Interfaces and Abstract classes.
What is an interface?
A type that cannot ever be created as an instanced object. It has a name and a set of methods, which an not implemented. The can provide the backbone for classes that implement said interface.
Name a couple fo interfaces used in JHotDraw.
Drawing Figure Connector Handle DrawingView Painter Etc.
TRUE or FALSE: A class can implement many interfaces at once.
True