google web toolkig · gwt-rpc is a good solution if handled with care someresult...

97
p.g.taboada | pgt technology scouting GmbH Google Web Toolkit Architecture Best Practices Donnerstag, 25. April 13

Upload: others

Post on 01-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

p.g.taboada | pgt technology scouting GmbH

Google Web Toolkit

Architecture

Best Practices

Donnerstag, 25. April 13

Page 2: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

http://gwtreferencelist.appspot.com

Donnerstag, 25. April 13

Page 3: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

‣GWT Development

‣Basics

‣Structuring the UI

‣Communication

‣Scaling

Donnerstag, 25. April 13

Page 4: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Shift happened

Java development, JS deployment,

Async,RPC,

RIA/ single page,...

Donnerstag, 25. April 13

Page 5: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

TextBox t = new TextBox();

RootPanel.get().add(t);

Donnerstag, 25. April 13

Page 6: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Browser Server

user action

full html response

full html response

full html response

user action

user action

Donnerstag, 25. April 13

Page 7: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Browser Server

event

first request

full html response

data

data request

data

data request

event

event

event

Donnerstag, 25. April 13

Page 8: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

low level, generic toolkitDonnerstag, 25. April 13

Page 9: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

let‘s build big thingsDonnerstag, 25. April 13

Page 10: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

TextBox t0 = new TextBox();TextBox t1 = new TextBox();TextBox t2 = new TextBox();TextBox t3 = new TextBox();TextBox t4 = new TextBox();

VerticalPanel...SplitPanel...ScrollPanel

RootPanel.get().add(mainPanel);

Donnerstag, 25. April 13

Page 11: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Run, Forrest. Run!Donnerstag, 25. April 13

Page 12: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

HopplaDonnerstag, 25. April 13

Page 13: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

framework wizardry needed

Donnerstag, 25. April 13

Page 14: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

‣GWT Development

‣Basics

‣Structuring the UI

‣Communication

‣Scaling

Donnerstag, 25. April 13

Page 15: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

BE CAREFUL. GWT DEVELOPMENTIS COMPLICATED HOT NEW STUFF.

Donnerstag, 25. April 13

Page 16: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

WELL, IT‘S NOT NEW...

Donnerstag, 25. April 13

Page 17: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

THERE IS NOT A MOMENT TO LOOSETHERE IS NOT A MOMENT TO LOOSEJan 2000 Jan 2005

XHTML 1.0Jan 2000

HTML 4.0.1Dez 1999

CSS 2Mai 1998

HTML 4.0 updateApril 1998

XHTML 1.1Mai 2001

HTML 2.0November 1995

HTML 4.0Dezember 1997

Java EE 1.2Dez 1999

JDK 1.1Feb 1997

Internet Explorer 6Aug 2001

JDK 1.0Jan 1996

CSS 2.1Feb 2004 – Jun 2011

CSS level 2 revision 1, often referred to as "CSS 2.1", fixes errors in CSS 2, removes poorly supported or not fully interoperable features and adds already-implemented browser extensions to the specification. In order to comply with the W3C Process for standardizing technical specifications, CSS 2.1 went back and forth between Working Draft status and Candidate Recommendation status for many years.

J2SE 1.2Dez 1998

J2SE 1.3Mai 2000

CSS 1Dez 1996

HTML 3.2Januar 1997

Donnerstag, 25. April 13

Page 18: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

nothing new hereDonnerstag, 25. April 13

Page 19: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

nothing new here too

Jan 2007

Donnerstag, 25. April 13

Page 20: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

how can I avoid this?Donnerstag, 25. April 13

Page 21: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

don‘t public instance the singletons

Donnerstag, 25. April 13

Page 22: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

event bus pleasehttp://jarrettws.blogspot.de/2010/05/public-transport.html

Donnerstag, 25. April 13

Page 23: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

eventbus.fireEvent(NotificationEvent.info("Daten wurden erfolgreich gespeichert"

));

Donnerstag, 25. April 13

Page 24: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

USE MVP!You will get used to it

Donnerstag, 25. April 13

Page 25: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

presenter model

clientFactory

eventBus

panel

view

Donnerstag, 25. April 13

Page 26: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

presenter

view interface

presenter interface

model

desktop view

tablet view mock viewDonnerstag, 25. April 13

Page 27: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

public interface LoginView extends View {

void setPresenter(LoginView.Presenter currentPresenter);

void presetEmailFieldWith(String email);

void doShowApplicationMetadata(AppData params);

public interface Presenter extends LemniscusPresenter {

void userLoginWith(String username, String password);

void userDidAskForRegistrationPlace();

void userWantsToChangePassword(

int verificationCode, String userEmail, String

newPasswordToUse);

void userRequestedVerificationCodeForPasswordChange(String email);

}

}

Donnerstag, 25. April 13

Page 28: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

public interface LoginView extends View {

void setPresenter(LoginView.Presenter currentPresenter);

void presetEmailFieldWith(String email);

void doShowApplicationMetadata(AppData params);

public interface Presenter extends LemniscusPresenter {

void userLoginWith(String username, String password);

void userDidAskForRegistrationPlace();

void userWantsToChangePassword(

int verificationCode, String userEmail, String newPasswordToUse);

void userRequestedVerificationCodeForPasswordChange(String email);

}

}

MyDesktopViewImpl extends Composite implements LoginView

Donnerstag, 25. April 13

Page 29: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

public interface LoginView extends View {

void setPresenter(LoginView.Presenter currentPresenter);

void presetEmailFieldWith(String email);

void doShowApplicationMetadata(AppData params);

public interface Presenter extends LemniscusPresenter {

void userLoginWith(String username, String password);

void userDidAskForRegistrationPlace();

void userWantsToChangePassword(

int verificationCode, String userEmail, String newPasswordToUse);

void userRequestedVerificationCodeForPasswordChange(String email);

}

}

MyLoginPresenter extends AA... implements LoginView.Presenter

Donnerstag, 25. April 13

Page 30: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

BUT ON IE 6 IT IS SO SLOW!

Donnerstag, 25. April 13

Page 31: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

BUT ON IE 7 IT IS SO SLOW!

Donnerstag, 25. April 13

Page 32: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

BUT ON IE 8 IT IS SO SLOW!

Donnerstag, 25. April 13

Page 33: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

BUT ON IE 9 IT IS SO SLOW!

Donnerstag, 25. April 13

Page 34: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

too many widgets ain‘t goodDonnerstag, 25. April 13

Page 35: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

CREATE CUSTOM WIDGETS

don‘t extend FlextTable

don‘t extend VerticalPaneldon‘t extend SimplePanel

CREATE CUSTOM EVENTS

Donnerstag, 25. April 13

Page 36: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

if you can, do it in CSS

@-webkit-keyframes redPulse { from { box-shadow: 0px 0px 2px #ff0033; } 50% { box-shadow: 0px 0px 10px #ff0033; } to

{ box-shadow: 0px 0px 2px #ff0033; }}

Donnerstag, 25. April 13

Page 37: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

use CSS layout

<g:LayoutPanel styleName="{B.style.mainContent}"> <g:layer left="0" right="340px" top="0" height="50%"> <g:SimpleLayoutPanel styleName="{B.style.mainWidget}" addStyleNames="{B.style.termineGlow}"> <ux:DashboardTermineDataGrid ui:field="terminetable" styleName="{B.style.mainWidgetContent}" /> </g:SimpleLayoutPanel> </g:layer> <g:layer right="0" width="340px" top="0" height="50%"> <g:SimpleLayoutPanel styleName="{B.style.mainWidget}" addStyleNames="{B.style.finanzenGlow}"> <ux:KWStatsDataGrid ui:field="statstable" styleName="{B.style.mainWidgetContent}" /> </g:SimpleLayoutPanel> </g:layer> <g:layer right="0" left="0" bottom="0" height="50%"> <g:SimpleLayoutPanel styleName="{B.style.mainWidget}" addStyleNames="{B.style.uebersichtGlow}"> <ux:WartelisteDataGrid ui:field="wartelistetable" styleName="{B.style.mainWidgetContent}" /> </g:SimpleLayoutPanel> </g:layer></g:LayoutPanel>

Donnerstag, 25. April 13

Page 38: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Ray Ryan - lessons learnedDonnerstag, 25. April 13

Page 39: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

‣GWT Development

‣Basics

‣Structuring the UI

‣Communication

‣Scaling

Donnerstag, 25. April 13

Page 40: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

„just do it“ pattern

„View A“

„View B“

mainPanel.setWiget( aWidget );

mainPanel.setWiget( bWidget );

some action

Donnerstag, 25. April 13

Page 41: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

hard to maintainDonnerstag, 25. April 13

Page 42: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

history management

from day one!

back button and refresh as a

feature (not a catastrophe)

Donnerstag, 25. April 13

Page 43: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

keep it stupid simple• use PLACES framework

for main level navigation

• if you really need to, nest activities for a second level. try not to.

• use dialogs for user input, showing data. dialogs are easily reused.

Donnerstag, 25. April 13

Page 44: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Once upon a time, a good designer does

good a good looking design...

‣ he will be using photoshop or dreamweaver‣ he will not use the

software‣ he will not build the

software‣ he will not maintain the

software

Donnerstag, 25. April 13

Page 45: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Donnerstag, 25. April 13

Page 46: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

top menue bound to places framework

Donnerstag, 25. April 13

Page 47: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

switching between places with fade in and out

Donnerstag, 25. April 13

Page 48: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

teach user to wait until application is ready again

Donnerstag, 25. April 13

Page 49: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

gives us enough time to load the required content

300ms out 500ms in

Donnerstag, 25. April 13

Page 50: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Komponents inside an

„activity“ fire non public,

custom events

Donnerstag, 25. April 13

Page 51: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

datepicker sends KW

selected event

Donnerstag, 25. April 13

Page 52: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

presenter may goto itself, view may be cached

Donnerstag, 25. April 13

Page 53: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

STATELESS VIEW

URL contains EVERYTHING needed to rebuild view

user hits reload

GWT apps starts, activity

gets fired

presenter loads data

from server

view is back again

Donnerstag, 25. April 13

Page 54: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

some actions don‘t require PLACE navigation at all

Donnerstag, 25. April 13

Page 55: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

use POPUPS to stay ABOVE navigation

Donnerstag, 25. April 13

Page 56: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

let POPUPS/ DIALOGS move slowly into view

pin POPUPS to one side of the

window

Donnerstag, 25. April 13

Page 57: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

let POPUPS/ DIALOGS move slowly into view

pin POPUPS to one side of the

window

Donnerstag, 25. April 13

Page 58: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Don‘t move your user away from his

„PLACE“ unless you have to.Search DIALOG

slides in from right side, stays on TOP

Donnerstag, 25. April 13

Page 59: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Navigation must not hurt

• The application shown uses only 3 levels of navigation, DOES NOT NEED MORE

• PLACES used for bookmarkable entry points/ back button navigation consistency

• Activities should be STATELESS, to survive page reloads

• Learn from OTHERS

Donnerstag, 25. April 13

Page 60: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

BEFORE YOU ADD THE LOGO TO THE TOP

HOW MANY PIXELS DO YOUR USERS HAVE? the designer or

marketing guy using photoshop is probably sitting in

front of a 27“ apple cinema

displayDonnerstag, 25. April 13

Page 61: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

‣GWT Development

‣Basics

‣Structuring the UI

‣Communication

‣Scaling

Donnerstag, 25. April 13

Page 62: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Honor the A in AJAX

‣ Javascript does not block Get over it

‣ Latency is not a myth

‣ Results must not arrive in the call order

Donnerstag, 25. April 13

Page 63: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

MARSHALLING / UNMARSHALLING IN JAVASCRIPT IS SLOW

Donnerstag, 25. April 13

Page 64: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

BUILDING A GENERIC FRAMEWORK FORMARSHALLING/ UNSMARSHALLING DATA SUCKS

Donnerstag, 25. April 13

Page 65: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

DON‘T BIND YOU NEXT 3 YEARS OF WORK AGAINST SOME COMMUNICATION PROTOCOLL

Donnerstag, 25. April 13

Page 66: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

LOADING TOO MUCH DATA WILL ALWAYS HURT

Donnerstag, 25. April 13

Page 67: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

GWT-RPC is a good solution if handled with care

SomeResult someMethodName(SomeParameter spo)

GWT-RPC binds many

methods into one interface

Interface Versioning

is a monstrous

thing

Donnerstag, 25. April 13

Page 68: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

SomeResult someMethodName(SomeParameter spo)

the method names bind the requests to the result

typesafety all the way

Donnerstag, 25. April 13

Page 69: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

USING GENERICS FOR TYPESAFETY, GET RID OF METHODS AND INTERFACES

Donnerstag, 25. April 13

Page 70: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

<A extends Action<R>, R extends Result> R execute(A action);

now we just one interface with one method

typesafety all the way

Donnerstag, 25. April 13

Page 71: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

command pattern

GOF Pattern

commonly used in Rich Clients

Donnerstag, 25. April 13

Page 72: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

someAction

someResult

someActionHandler

Donnerstag, 25. April 13

Page 73: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

someAction

someResult

someActionHandlerPOJOS

Donnerstag, 25. April 13

Page 74: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

someAction

someResult

someActionHandlermultipleversions

someActionV2

someActionHandlerV2

Donnerstag, 25. April 13

Page 75: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

someAction

someResult

someActionHandlermultipleversions

someActionV2

someActionHandlerV2

someResultV2

Donnerstag, 25. April 13

Page 76: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

someAction

someResult

someActionHandler

GWT-RPC

client server

batchingcachingsecurity

cachingexception translationsecurity

GWT client

Donnerstag, 25. April 13

Page 77: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

someAction

someResult

someActionHandler

RMI / HTTPInvoker

client server

batchingcachingsecurity

cachingexception translationsecurity

Java client

Donnerstag, 25. April 13

Page 78: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

someAction

someResult

someActionHandler

JSON-servlet

client server

batchingcachingsecurity

cachingexception translationsecurity

Mobile client

Donnerstag, 25. April 13

Page 79: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

batchAction

someAction1

batchActionHandler

someAction2

someAction3

batchResult

someResult1

someResult2

someResult3

client server

batching can be manual or

automatic

server executesactions in given order

Donnerstag, 25. April 13

Page 80: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

BATCH EXECUTION ALLOWS FOR FINE GRAINED COMMANDS AND REUSE

Donnerstag, 25. April 13

Page 81: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

toggleTerminMetadata

reloadDashboardTermine

BooleanResult

DataListResult<Termin>

Donnerstag, 25. April 13

Page 82: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

toggleTerminMetadata

reloadTermin

BooleanResult

DataResult<Termin>

Donnerstag, 25. April 13

Page 83: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

toggleTerminMetadata

loadMonthStats

BooleanResult

DataResult<MonthStats>

loadMonthTermine DataListResult<Termin>

Donnerstag, 25. April 13

Page 84: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

‣GWT Development

‣Basics

‣Structuring the UI

‣Communication

‣Scaling

Donnerstag, 25. April 13

Page 85: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

• Every client brings his own CPU power

• The client does the page rendering

• GWT provides different ways to reduce number of requests even more

• The server must „only“ authenticate the user and provide the data, perform the actions requested by the client

GWT scaling is easy...

Donnerstag, 25. April 13

Page 86: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

WHAT CAN POSSIBLY GO WRONG?

Donnerstag, 25. April 13

Page 87: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

LETS TALK HIGH TRAFFIC...HIGH TRAFFIC IS WHEN ONE SERVER IS NOT ENOUGH

Donnerstag, 25. April 13

Page 88: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

• Bandwith issues

• Connection pool bottlenecks

• Thread pool bottlenecks

• CPU bottlenecks caused by reflection API calls

• High JVM garbage collection CPU usage

HIGH TRAFFIC PROBLEMS

Donnerstag, 25. April 13

Page 89: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

NOT REALLY GWT PROBLEMS,BUT WHAT CAN WE DO?

Donnerstag, 25. April 13

Page 90: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

TX TX

TX TX

TX

TX

TX TX

TX

TXavoid „tx collisions“

Donnerstag, 25. April 13

Page 91: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

TX TX TX TX

TX

TXTX

TX TX

TX

TX

TXTX

TX

TX

load small portions of data, do it often

Donnerstag, 25. April 13

Page 92: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Donnerstag, 25. April 13

Page 93: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

IMPLEMENT REAL LOAD BALANCINGEACH REQUEST GOES TO THE NEXT AVAILABLE SERVER

Donnerstag, 25. April 13

Page 94: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

• Don‘t stick a session to a server.

Why send a user over and over again to a possible overloaded server?

• Don‘t store anything on the HTTP session. Let the load balancer balance the load.

• Session replication is expensive and does not scale well

SCALING HOW-TO

Donnerstag, 25. April 13

Page 95: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Webserver

Webserver

LB Webserver

Webserver

Webserver

Session Cache

STATELESS WEB

Webserver

Donnerstag, 25. April 13

Page 96: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Session Cache

Session state should not change, just expire

Session state could contain user id, client id, session id, user roles

If session cache becomes bottleneck, use distributed cache, eg. memcached

Session Cache

Session Cache

Donnerstag, 25. April 13

Page 97: Google Web Toolkig · GWT-RPC is a good solution if handled with care SomeResult someMethodName(SomeParameter spo) GWT-RPC binds many methods into one interface Interface Versioning

Thanks!Donnerstag, 25. April 13