+ All Categories
Home > Technology > T 0230 Google Wave Powered By Gwt

T 0230 Google Wave Powered By Gwt

Date post: 15-May-2015
Category:
Upload: supertoy2015
View: 1,202 times
Download: 2 times
Share this document with a friend
Popular Tags:
33
Transcript
Page 1: T 0230 Google Wave Powered By Gwt
Page 2: T 0230 Google Wave Powered By Gwt

Google Wave Client:Powered by GWTAdam Schuck28 May, 2009

Page 3: T 0230 Google Wave Powered By Gwt

Google Wave client

abusedetection savedsearches

folders

contacts

presence

search authentication

accesscontrol playback

waves

attachments

gadgets

Page 4: T 0230 Google Wave Powered By Gwt

To GWT or not to GWTClient architectureChanges in GWTImproving GearsPerformanceMobile clientTestabilityUI testing with WebDriver

Outline

Page 5: T 0230 Google Wave Powered By Gwt

fast!stunning!think beyond the browseroptimistic

Wave UI Requirements

<Demo>

Page 6: T 0230 Google Wave Powered By Gwt

What is GWT?Java (compiled to JS)

use your favourite IDE (Eclipse, IntelliJ)can share code between client + server

Deferred bindingJavaScript Native Interface (JSNI)

To GWT or not to GWT

?

Page 7: T 0230 Google Wave Powered By Gwt

Prototype demoed late 2007Then: The No. 1 GWT Skeptic: meWhat changed my mind?Myth: "Can't build a real app!"Mindset: e.g. scrolly, panels

To GWT or not to GWT

?

Page 8: T 0230 Google Wave Powered By Gwt

Bi-directional communication channelProtocol compiler

Generates interfaces, client + server implementations

Concurrency Control stackOther Talks: Extending Wave; Under the Hood

Client Architecture

Page 9: T 0230 Google Wave Powered By Gwt

FF3

Safari

Chrome

In development:IE7

Android

iPhone

Supported Browsers

Page 10: T 0230 Google Wave Powered By Gwt

Evolution of GWT

Page 11: T 0230 Google Wave Powered By Gwt

GWT "areas for improvement" late 2007:UI code cumbersomeCross-browser CSSJSON handling heavy-handedDebugging environment != browserMonolithic compile -> everything downloaded at startMapping from Java <-> JS unclearInefficiencies in compiler

What was GWT missing, late 2007?

Page 12: T 0230 Google Wave Powered By Gwt

Issue: creating widgets is time-consuming and heavy handed

I have to write how much code?

promptPanel = new DivPanel();VerticalPanel panel = new VerticalPanel();HTML heading = new HTML("Identification");Label lblPrompt = new Label("Please identify me by:");final RadioButton r1 = new RadioButton("identity", "my Google Wave account (" + uName + ")");Image imgUser = new Image("images/" + uImage);final RadioButton r2 = new RadioButton("identity", "the following name: ");Image imgBlog = new Image("images/" + blog.getImage());final TextBox t = new TextBox();HorizontalPanel hPanel = new HorizontalPanel();Button btnOk = new Button("OK");Button btnCancel = new Button("Cancel");

...

Page 13: T 0230 Google Wave Powered By Gwt

Solution: UiBinder (formerly declarative UI)

Templates allow our UI designer to modify the UI directly!

I have to write how much code?

<ui:UiBinder xmlns:ui='urn:ui.com.google.gwt.uibinder'> <div> Hello, <span ui:field='nameSpan'/>. </div></ui:UiBinder>

See: http://code.google.com/p/google-web-toolkit-incubator/wiki/UiBinder

Page 14: T 0230 Google Wave Powered By Gwt

Issue: GWT abstracts cross-browser JS quirks, but not CSS

Solution: StyleInjector + CssResourceProvides:

Validation

Minification + Image SpritingAllows modularization of CSS: download only when neededDifferent CSS for different browsers (compile-time):

But most cross-browser bugs are CSS!

@if user.agent safari { \-webkit-border-radius: 5px;}

See: http://code.google.com/p/google-web-toolkit/wiki/CssResource

Page 15: T 0230 Google Wave Powered By Gwt

Issue: JSON handling inefficient, requires extra objects

Solution: JavaScriptObject (JSO)

Subclass JavaScriptObject to create an "overlay type"avoid using JSONObject: use JSO / StringBuffer

Inefficient JSON handling

private native void setPayload(String val) /*-{ this.payload = val;}-*/;

private native String getPayload() /*-{ return this.payload;}-*/;

See: http://code.google.com/p/google-web-toolkit/wiki/OverlayTypes

Page 16: T 0230 Google Wave Powered By Gwt

Issue: each browser behaves slightly differently to hosted mode

Solution: Out-of-process Hosted Mode (OOPHM)Browser plugin to debug in Eclipse, but run in real browser!

Firebug only for FF:OOPHM allows Java debugging in FF, Safari, IE (so far)

See: http://code.google.com/p/google-web-toolkit/wiki/DesignOOPHM

<Time for a demo!>

Debugging in Eclipse rocks! - but...

Page 17: T 0230 Google Wave Powered By Gwt

Issue: download size >1 MB (pre-gzip) and counting...

Distribute as a CD-ROM?

Page 18: T 0230 Google Wave Powered By Gwt

Solution: runAsync (dynamic loading of code)

GWT.runAsync() signals a "cut point" to the GWT compiler:Download what you need, when you need it

Resources (CSS, images, msgs) come with the code that uses itAutomatically handled by GWT compiler!

Distribute as a CD-ROM? No!

public void onNewWaveClicked() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { WaveCreator.createNewWave(); } });}

See: http://code.google.com/p/google-web-toolkit/wiki/CodeSplitting

Page 19: T 0230 Google Wave Powered By Gwt

Down and to the right

Page 20: T 0230 Google Wave Powered By Gwt

Issue: need to know what Java causes the most JS

Solution: Story-of-your-Compile (SOYC) reportsWhat is it?: Java package to JS breakdown report

Helped us identify:messages too largecompiled class nameswhat's in the initial download

e.g. before and after messages optimisation project

Where's all the JS coming from?

Page 21: T 0230 Google Wave Powered By Gwt

Issue: we need interfaces for our messages, because:client + server both have common librariesthey should be implementation-agnostic

Solution: GWT's SingleJsoImplIn order to inline, JSOs cannot have polymorphic dispatchSingleJsoImpl: allow at most one JSO class to implement any interface

JSOs cannot implement interfaces

Page 22: T 0230 Google Wave Powered By Gwt

Declarative UI / UiBinderStyleInjector + CssResource + ClientBundleJavaScriptObjectOOPHMrunAsyncStory-of-your-Compile (SOYC)SingleJsoImpl-XdisableClassMetadata (saved us ~90KB)

GWT changes summarised

Page 23: T 0230 Google Wave Powered By Gwt

Improving the user experience

Page 24: T 0230 Google Wave Powered By Gwt

Client-side Thumbnailingsend thumbnails before image upload uses WorkerPool to avoid blocking UI

Desktop Drag + DropResumable uploading

Improving Gears

Page 25: T 0230 Google Wave Powered By Gwt

Startup:runAsyncfast startinline images + CSSsmaller downloadstats collectionserver-side script selection

Loaded client:optimistic UIprefetchingflyweight patternrendering tricks (prefer DOM over GWT's Widget)

Performance

Page 26: T 0230 Google Wave Powered By Gwt

GWT deferred binding saves the day!

v1 AJAX onlyiPhone browser always running

browser starts up faster than native apps

uses mobile-specific communication channel

HTML5 / Gears caching: AppCache manifest GWT linker

<Time for another demo!>

Mobile Client

Page 27: T 0230 Google Wave Powered By Gwt

Testing

Page 28: T 0230 Google Wave Powered By Gwt

Model View Presenter

Prefer JUnit tests over GWTTestCaseBrowser automation: WebDriver

Testability

Page 29: T 0230 Google Wave Powered By Gwt

What is it?developer-focused tool for browser automation

Why do we use it?native keyboard and mouse events, rather than synthesised via JS

Challenges:adopted early by Waveincomplete

Google Wave's commitmentWhat's new?

iPhoneDriverRemoteWebdriver on a grid

<Demo!>

WebDriver

Page 30: T 0230 Google Wave Powered By Gwt

Avoid xpath: slow (JS on IE), brittlerather: ids, names, and sub-dom navigation

Intent of tests should be clear: use literate programming

Each UI class has a WebDriver helper class

WebDriver Tips

// Type in some stuffBlipPanel blip = wavePanel.getFocusedBlip();Editor editor = blip.getEditor();editor.type("Do you know your abc?") .enter() .type("And your alpha beta gamma?") .back() .type("...?");editor.check("<p _t='title'>Do you know your abc?</p>" + "<p>And your alpha beta gamma...?|</p>");// This will cause a contacts popupblip.clickSubmit();assertEquals("Do you know your abc?", wavePanel.getTitle());

Page 31: T 0230 Google Wave Powered By Gwt

To GWT or not to GWT?

Client architecture

Changes in GWT

Improving Gears

Performance

Mobile client

Testability

UI testing with WebDriver

Summary

Page 32: T 0230 Google Wave Powered By Gwt

Thanks! Questions?

Feedback please! http://haveasec.com/io

Page 33: T 0230 Google Wave Powered By Gwt

Recommended