The Google Web Toolkit Experience

60
Agile AJAX: The Google Web Toolkit Experience Paul Infield-Harm paul@infield-harm.org www.infield-harm.org Daniel Wellman [email protected] blog.danielwellman.com New York • Boston www.cyrusinnovation.com

Transcript of The Google Web Toolkit Experience

Page 2: The Google Web Toolkit Experience
Page 3: The Google Web Toolkit Experience
Page 4: The Google Web Toolkit Experience

What is

Google Web Toolkit ?

Page 5: The Google Web Toolkit Experience

Java

Page 6: The Google Web Toolkit Experience

Java to JavaScriptcompiler

Java JavaScript

.java.java.java.java.javaCompiler

.js

.js

.js

.js

Page 7: The Google Web Toolkit Experience

Why?

Page 8: The Google Web Toolkit Experience

“...because there already are so many

great tools out there, not to mention

scads of books, articles, libraries, and expertise.”

- The GWT Team

Page 9: The Google Web Toolkit Experience

Demo

Page 10: The Google Web Toolkit Experience

A Taste of GWT

• Application, Java source, generated js

• Exploratory dev in hosted mode

• Making a change, test-first

Page 11: The Google Web Toolkit Experience

A Taste of GWT

• Application, Java source, generated js

• Exploratory dev in hosted mode

• Making a change, test-first

Page 12: The Google Web Toolkit Experience

A Taste of GWT

• Application, Java source, generated js

• Exploratory dev in hosted mode

• Making a change, test-first

Page 13: The Google Web Toolkit Experience

A Taste of GWT

• Application, Java source, generated js

• Exploratory dev in hosted mode

• Making a change, test-first

Page 14: The Google Web Toolkit Experience

Application, Java source, generated JS

Page 15: The Google Web Toolkit Experience

Exploratory dev in hosted mode

Page 16: The Google Web Toolkit Experience

Making a change, test-first

Page 17: The Google Web Toolkit Experience

http://www.flickr.com/photos/clothfairy/ CC BY 2.0photo by clothfairy

JSNI

Page 18: The Google Web Toolkit Experience

GWT and

Agile

Development

Practices

Page 19: The Google Web Toolkit Experience

Agile DevelopmentPractices

• Refactoring

• Performance Optimization

• Test-Driven Development

• Collective Code Ownership

• Continuous Integration

Page 20: The Google Web Toolkit Experience

Refactoring

Page 21: The Google Web Toolkit Experience
Page 22: The Google Web Toolkit Experience

Wrap Return ValueInvert Boolean

Safe DeleteMove Instance Method

Inline ConstantExtract Subclass

Replace Method Code DuplicatesConvert To Instance Method

RenameMove Inner Class to Upper Level

Change Method SignatureMake Method StaticCopy/Clone ClassExtract Method

Introduce VariableIntroduce Field

Introduce ConstantIntroduce Parameter

Extract InterfaceExtract Superclass

Use Interface Where PossiblePull Members Up

Push Members DownReplace Inheritance with Delegation

Inline Local VariableInline Method

Convert Anonymous Class to InnerEncapsulate Fields

Replace Temp With QueryReplace Constructor With Factory Method

Java RefactoringsJavaScript Refactorings

Safe DeleteRename

Move/Copy FileIntroduce Variable

Introduce FieldIntroduce Constant

Rem

ove

Mid

dlem

an

Extr

act M

etho

d O

bjec

t

Inline Superclass

Introduce Parameter O

bject

Type M

igrati

on Extract Class

Page 23: The Google Web Toolkit Experience

Typical Java Web Template

<div> <span>${title}</span> <a href="..."><img src="..."/></a> <a href="..."><img src="..."/></a> </div>

Page 24: The Google Web Toolkit Experience

GWT Layout

label = new Label(title);panel.add(label);

upButton = new Image("...");panel.add(upButton); removeButton = new Image("...");panel.add(removeButton);

Page 25: The Google Web Toolkit Experience

Refactored GWT

new BookPanel(title);

Page 26: The Google Web Toolkit Experience

PerformanceOptimization

Page 27: The Google Web Toolkit Experience

BetterJavaScript code than

you would write

by hand

- “Making GWT Better” on GWT Project Page

photo by clothfairy

Page 28: The Google Web Toolkit Experience

OptimizingCompiler

photo by ralphbijker

Page 29: The Google Web Toolkit Experience

Name That Compile!

classCalculator{publicintadd(intx,inty){returnx+y;}}

CalculatormyCalc=newCalculator();Window.alert((myCalc.add(3,2));

Page 30: The Google Web Toolkit Experience

Compiles To:

alert(5)

Page 31: The Google Web Toolkit Experience
Page 32: The Google Web Toolkit Experience

Whole-Program Optimization

Page 33: The Google Web Toolkit Experience

Whole-ProgramOptimization

Java Library

Compiler

JavaScript

Page 34: The Google Web Toolkit Experience

... but no reflection.

employee.set("firstName", "Fred");X

Page 35: The Google Web Toolkit Experience

Simple Design

photo by Alicia Solario

Page 36: The Google Web Toolkit Experience

Test-Driven Development

Page 37: The Google Web Toolkit Experience

JUnitTestNG

FitConcordion

Page 38: The Google Web Toolkit Experience

Three ways to test

Page 39: The Google Web Toolkit Experience

Plain JUnit

@TestpublicvoidadditionsGoToTopOfList(){ startingWithTitles("First added");

model.addTitle("Second added"); assertThat(model.getTitles().get(0), is("Second added"));}

Page 40: The Google Web Toolkit Experience

In a Real Browser

Page 41: The Google Web Toolkit Experience

In the Hosted Mode Browser

GWTTestCase

Page 42: The Google Web Toolkit Experience

How do you test UI?

Page 43: The Google Web Toolkit Experience

Model-View-Presenter

View

Presenter

Model

Page 44: The Google Web Toolkit Experience

Collective Code Ownership

photo by sanja gjenero

Page 45: The Google Web Toolkit Experience

Same Code on Browser and Server

JavaObject

Page 46: The Google Web Toolkit Experience

Front End Developers

Server Developers

Developers

Page 47: The Google Web Toolkit Experience

Code-based UI LayoutHorizontalPanel panel = new HorizontalPanel();panel.add(new TextBox());panel.add(new Button(...));panel.add(new Image(...);

Developers UI Designers

:-) :-(

Page 48: The Google Web Toolkit Experience

Cross-browser CSSis still hard

Page 49: The Google Web Toolkit Experience

ContinuousIntegration

photo by wilhei

Page 50: The Google Web Toolkit Experience

Build Tools

Page 51: The Google Web Toolkit Experience

Build Servers

Hudson

Page 52: The Google Web Toolkit Experience

Static Analysis& Code Quality Tools

Checkstyle

Page 53: The Google Web Toolkit Experience

Image by Svilen Mushkatov

When

should you

use GWT?

Page 54: The Google Web Toolkit Experience

photo by Boby Dimitrov

Page 55: The Google Web Toolkit Experience

Is this a web siteor a web application?

Web site Web application

Page 56: The Google Web Toolkit Experience

photo by Vidiot

Page 57: The Google Web Toolkit Experience
Page 58: The Google Web Toolkit Experience
Page 59: The Google Web Toolkit Experience

Checkstyle

JUnit

TestNG

FitConcordion