MiniDraw Introducing a framework... and a few patterns



Similar documents
Implementação. Interfaces Pessoa Máquina 2010/ Salvador Abreu baseado em material Alan Dix. Thursday, June 2, 2011

TATJA: A Test Automation Tool for Java Applets

GUI and Web Programming

Assignment # 2: Design Patterns and GUIs

Event processing in Java: what happens when you click?

A generic framework for game development

Model-View-Controller (MVC) Design Pattern

Developing GUI Applications: Architectural Patterns Revisited

ARCHITECTURAL DESIGN OF MODERN WEB APPLICATIONS

JUnit. Introduction to Unit Testing in Java

Oracle Application Development Framework Overview

Java (12 Weeks) Introduction to Java Programming Language

Web Presentation Layer Architecture

Teaching Object-Oriented Software Design within the Context of Software Frameworks

Table of Contents. Adding Build Targets to the SDK 8 The Android Developer Tools (ADT) Plug-in for Eclipse 9

Monitoring Infrastructure (MIS) Software Architecture Document. Version 1.1

NetBeans and GlassFish v 2.1 Creating a Healthcare Facility Visual Web Application

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

Extending Desktop Applications to the Web

Application Programming on the Mac COSC346

: provid.ir

Patterns in. Lecture 2 GoF Design Patterns Creational. Sharif University of Technology. Department of Computer Engineering

NASA Workflow Tool. User Guide. September 29, 2010

JOURNAL OF OBJECT TECHNOLOGY

BUSINESS RULES CONCEPTS... 2 BUSINESS RULE ENGINE ARCHITECTURE By using the RETE Algorithm Benefits of RETE Algorithm...

JiST Graphical User Interface Event Viewer. Mark Fong

Embedded Software Development with MPS

Winery A Modeling Tool for TOSCA-based Cloud Applications

Agile Business Suite: a 4GL environment for.net developers DEVELOPMENT, MAINTENANCE AND DEPLOYMENT OF LARGE, COMPLEX BACK-OFFICE APPLICATIONS

Getting Started with CodeXL

Easy configuration of NETCONF devices

Oracle Service Bus Examples and Tutorials

Customer Bank Account Management System Technical Specification Document

Best Practices in Qt Quick/QML. Langston Ball Senior Qt Developer ICS, Inc.

Programming with the Microsoft.NET Framework Using Microsoft Visual Studio 2005 (VB)

Agile processes. Extreme Programming, an agile software development process. Extreme Programming. Risk: The Basic Problem

Building Applications with Protégé: An Overview. Protégé Conference July 23, 2006

Architectural Patterns. Layers: Pattern. Architectural Pattern Examples. Layer 3. Component 3.1. Layer 2. Component 2.1 Component 2.2.

MA-WA1920: Enterprise iphone and ipad Programming

ORACLE MOBILE APPLICATION FRAMEWORK DATA SHEET

XFlash A Web Application Design Framework with Model-Driven Methodology

Design Patterns. Design patterns are known solutions for common problems. Design patterns give us a system of names and ideas for common problems.

E4 development: examples, methods and tools. Eclipse Con France 2014

Web Application Architectures

Design. in NetBeans 6.0

Evaluating OO-CASE tools: OO research meets practice

Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Mobile Apps with App Inventor

Getting Started with Telerik Data Access. Contents

Object Oriented Design

Aspect-Oriented Programming

Cassandra 2.0: Tutorial

Semantic Description of Distributed Business Processes

Fundamentals of Java Programming

How To Use The Command Pattern In Java.Com (Programming) To Create A Program That Is Atomic And Is Not A Command Pattern (Programmer)

How To Design Your Code In Php (Php)

Software Development Kit

GUI Event-Driven Programming

Umbrello UML Modeller Handbook

Progress Report Aspect Oriented Programming meets Design Patterns. Academic Programme MSc in Advanced Computer Science. Guillermo Antonio Toro Bayona

A Brief Analysis of Web Design Patterns

Design and Functional Specification

Java Web Services Training

A standards-based approach to application integration

Génie Logiciel et Gestion de Projets. Patterns

3D Animation of Java Program Execution for Teaching Object Oriented Concepts

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

QUICK START GUIDE

An Open Framework for Reverse Engineering Graph Data Visualization. Alexandru C. Telea Eindhoven University of Technology The Netherlands.

WebSphere MQ Oracle Enterprise Gateway Integration Guide

Automate Your BI Administration to Save Millions with Command Manager and System Manager

Johannes Sametinger. C. Doppler Laboratory for Software Engineering Johannes Kepler University of Linz A-4040 Linz, Austria

Scientific m-learning. 4-7 June Mobile Application Development using App Inventor for Android Devices

Introduction to Service Oriented Architectures (SOA)

The VB development environment


Toad Data Modeler - Features Matrix

High-level Design. What is software architecture?

COMMUNITY COLLEGE OF CITY UNIVERSITY CITY UNIVERSITY OF HONG KONG

New Web Application Development Tool and Its MDA-Based Support Methodology

Lesson 1 Introduction to Rapid Application Development using Visual Basic

How do APIs evolve? A story of refactoring

Experiences with 2-D and 3-D Mathematical Plots on the Java Platform

Visual Paradigm Quick Start

Managing Variability in Software Architectures 1 Felix Bachmann*

Unit Testing & JUnit

PIE. Internal Structure

ITS. Java WebService. ITS Data-Solutions Pvt Ltd BENEFITS OF ATTENDANCE:

Flash Tutorial Part I

Japan Communication India Skill Development Center

An introduction to creating JSF applications in Rational Application Developer Version 8.0

Creating XML Report Web Services

Transcription:

MiniDraw Introducing a framework... and a few patterns What is it? [Demo] 2 1

What do I get? MiniDraw helps you building apps that have 2D image based graphics GIF files Optimized repainting Direct manipulation Manipulate objects directly using the mouse Semantic constraints Keep objects semantically linked 3 History MiniDraw is downsized from JHotDraw JHotDraw Thomas Eggenschwiler and Erich Gamma Java version of HotDraw HotDraw Kent Beck and Ward Cunningham. Part of a smalltalk research project that lead to the ideas we now call design patterns and frameworks 4 2

MiniDraw MiniDraw supporting board games mainly cut down detail for teaching purposes MiniDraw: compositional design (most of the time) JHotDraw: polymorphic design (quite a lot of the time) Newest addition BoardGame extension: High support for board games 5 Our first MiniDraw application 6 3

DrawingEditor Project manager /Redaktør Default implementation Figure Visible element ImageFigure Drawing container of figures Tool = controller Factory create impl. of MiniDraw roles DrawingView view type to use... 7 The Patterns in MiniDraw Not what but why? The 3-1-2 principles in action again... 8 4

MiniDraw software architecture Main JHotDraw architecture remains Model-View-Controller architectural pattern Drawing-DrawingView-Tool Observer pattern event mechanism 9 MVC problem statement Challenge: writing programs with a graphical user interface multiple open windows showing the same data keeping them consistent manipulating data in many different ways by direct manipulation (eg. move, resize, delete, create,...) i.e. switching tool will switch the object manipulation 10 5

Challenge 1 Keeping multiple windows consistent? Analysis: Data is shared but visualization is variable! Data visualisation is variable behaviour Responsibility to visualize data is expressed in interface: View Instead of data object (model) itself is responsible for drawing graphics it lets someone else do the job: the views Model * <<interface>> View update() View A View A 11 Challenge 2 Few mouse events (down, up, drag) translate to open-ended number of actions (move, resize, create,?) on data. Events are the same but manipulation is variable Data manipulation is variable behaviour Responsibility to manipulate data is expressed in interface: Controller Instead of graphical view itself is responsible for manipulating data it lets someone else do the job: the controller Select View <<interface>> Controller mousedrag() Move Model 12 6

Observer Challenge 1: Also known as observer pattern Intent Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. 13 Observer: Structure 14 7

Observer Protocol Protocol: A convention detailing the expected sequence of interactions or actions expected by a set of roles. 15 Observer Benefits open ended number of viewer types (run-time binding) need not be known at develop time change by addition, not by modification... any number of views open at the same time when executing all guarantied to be synchronized Liabilities update sequence can become cyclic or costly to maintain 16 8

State Challenge 2: Also known as state pattern Intent Allow an object to alter its behaviour when its internal state changes. The object will appear to change its class. draw rectangle state select object state 17 State Consequences the manipulation that is active determine the application state ( am I moving or resizing figures? ) open ended number of manipulations (run-time binding) need not know all states at compile time change by addition... 18 9

Selected Tool defines the State In MiniDraw (HotDraw) the editor is in a state that determines how mouse events are interpreted do they move a checker, do they select a set of figures, or do they create a rectangle? Mouse events are forwarded to the editor s tool. By changing the tool I change how mouse events are interpreted. 19 MVC The MVC is an architectural pattern But the engine behind the scene is a careful combination of state and observer... That again are example of using the 3-1-2 variability handling process. 20 10

Static view 21 Responsibilities 22 11

Dynamics 23 MiniDraw 24 12

MiniDraw: Static+Pattern View 25 Tool: The Controller role 26 13

MiniDraw: Tool Interaction Basic paradigm: Direct Manipulation [Demo: puzzle] 27 View -> Controller interaction Mouse events do hit the JPanel, but MiniDraw simply delegate to its active tool... 28 14

Example Tool Scenario: User drags image figure around. Then a DragTracker is the active tool: 29 The real story is somewhat more complex as it involves a bit more delegation J StandardDrawingView is-a JPanel. This view requests access to the editor s current tool 30 15

Code view It is very simple to set a new tool: editor.settool( t ); where t is the tool you want to become active. NullTool is a Null Object: a tool that does nothing. 31 Drawing: The Model role 32 16

MiniDraw: Drawing Static View 33 MiniDraw: Drawing But how does the view get repainted? Double observer chain Figure notifies drawing notifies drawing view. 34 17

Exercise Observer pattern has two roles Subject: Container of data Observer: Object to notify upon data changes Who are who here??? DrawingView Drawing Figure 35 DrawingView: the View role 36 18

View The View is rather simple JPanel to couple MiniDraw to concrete Swing GUI implementation Listen to mouse events to forward them to tool/controller. 37 The Compositional Advantage Note that this design combines two frameworks MiniDraw and Swing If DrawingView was not an interface then N 38 19

DrawingEditor: The Coordinator 39 Static View 40 20

Implementation 41 Default Implementations Most MiniDraw roles have default implementations: Interface X has default implementation StandardX Drawing -> StandardDrawing There are also some partial implementations: Interface X has partial implementation AbstractX Tool -> AbstractTool Figure -> AbstractFigure 42 21

Compositional Design Complex behaviour as a result of combining simple behaviour... Example: StandardDrawing Responsibilities 43 How do we do that? Encapsulate major responsibilities in separate objects and compose behaviour Refactoring pending! 44 22

Code view: delegations! Examples: 45 What do we achieve? Implementing the HotCiv UnitDrawing The figure collection must behave radically different from what the StandardDrawing does but I can reuse the selection and drawing-change handler behaviour directly! 46 23

MiniDraw Variability Points 47 Variability points Images By putting GIF images in the right folder and use them through ImageFigures Tools Implement Tool and invoke editor.settool(t) Figures You may make any new type you wish Drawing Own collection of figures (e.g. observe a game instance) Observer Figure changes Make semantic constraints Views Special purpose rendering 48 24

Summary MiniDraw is A framework: A skeleton application that can be tailored for a specific purpose A demonstration: of MVC, Observer, State, Abstract Factory, Null Object, Strategy,... of compositional design: Make complex behaviour by combining simpler behaviours A basis: for the mandatory project GUI. 49 25