gwtcon 2015 - beyond gwt 3.0 panic

Post on 06-Jan-2017

1.908 Views

Category:

Presentations & Public Speaking

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

(ARCHITECTING WEB APPLICATIONS WITHOUT GWT-USER)

Beyond GWT 3.0 Panic

Cristiano Costantini @cristcost +CristianoCostantini http://lnkdin.me/p/cristianocostantini

GWT and ServiceMix project: 270K LoC, 5500 classes, more than 200 Maven modules

GWT MEET-UP 2015“GWT 2.8 and Beyond” , by Ray Cromwel l , Goktug Gokdogan

OK… WHAT DO WE DO NOW?

STOP USING GWT?

No, I want to reuse Java in Web Appl icat ions , mobi le platforms and off-

course in the Java Backend

STOP USING GWT?

1st. remove GWT-User from dependencies

2nd. don’t use JSNI, use JsInterop

3rd. don’t use Widgets, use Polymer

4th. don’t use IDE plugins*

5th. don’t use GWT RPC

Experiments Checklist:

1st. remove GWT-User from dependencies

2nd. don’t use JSNI, use JsInterop

3rd. don’t use Widgets, use Polymer

4th. don’t use IDE plugins*

5th. don’t use GWT RPC

LET’S PUT IT INTO PRACTICE

Experiments Checklist:

INTRODUCING WUnit an example application to test our

survival strategy

INTRODUCING WUNIT

WUNIT IS A UNIT TEST FRAMEWORK FOR…

INTRODUCING WUNIT

WUNIT IS A UNIT TEST FRAMEWORK FOR…

INTRODUCING WUNIT

…WARHAMMER, THE GAME

Testing which “Unit” is the best is really slow

Testing needs throwing a lot of dice

Using the “Assault Dice” app…

…solves only part of the problem

SO IT CAME

WUnit

DEMO

MANUAL

DICE APP

WUNIT

0 12,5 25 37,5 50

BENCHMARK

(Minutes to test two units)

AT FIRST WUNIT IS BORN WITH THIS ARCHITECTURE

CONSOLE ENGINE MODEL

POJOJavaSystem.out

THE VALUE OF USING JAVA TO IMPLEMENT THE GAME LOGIC

ENGINE

JavaThis code is so much complex

(Warhammer rules are so) that I wouldn’t attempt to write it without a full OOP language with solid development tools

THE VALUE OF USING JAVA TO IMPLEMENT THE GAME LOGIC

ENGINE

JavaThis code is so much complex

(Warhammer rules are so) that I wouldn’t attempt to write it without a full OOP language with solid development tools

THE VALUE OF USING JAVA TO IMPLEMENT THE GAME LOGIC

ENGINE

JavaThis code is so much complex

(Warhammer rules are so) that I wouldn’t attempt to write it without a full OOP language with solid development tools

THE VALUE OF USING JAVA TO IMPLEMENT THE GAME LOGIC

ENGINE

JavaThis code is so much complex

(Warhammer rules are so) that I wouldn’t attempt to write it without a full OOP language with solid development tools

WUnit ’s Engine is implemented in Java

Developed with strong TDD (coverage is about 93.6%)

REUSE - REUSE - REUSE

AIM CROSS-PLATFORMCONSOLE

ENGINE MODEL

POJOJava

System.out

WEB

ANDROID

GWT/j2cl

Android

iOS

j2objc

…AND THEN I WANTED TO TO BUILD AN USER INTERFACE FOR WUNIT:

HOW DID I DID IT?

(Singular not avai lable)

HOW TO USE GWT AND NOT GWT-USER

(Experiments made with WUnit prototype)

ARCHITECTING WEB APPLICATIONS FOR REUSE

VIEW INPUT

PRESENTER ENGINE MODEL

VIEW OUTPUT

written with POJO

written in (pure) Java

written in GWT/JS

written in Polymer

Note: Engine and Model are compiled to Javascript and run on the browser

thanks to javaemul !

REMOVE GWT-USER FROM DEPENDENCIES1st

…but i t comes the f irst fai lure!

JsInterop annotat ions and EntryPoint interface are ins ide GWT-user.

REMOVE GWT-USER FROM DEPENDENCIES1st

…but i t comes the f irst fai lure!

JsInterop annotat ions and EntryPoint interface are ins ide GWT-user.

Then, just avoid using anything else from GWT-user…

REMOVE GWT-USER FROM DEPENDENCIES1st

…and avoid inher i t ing “User” module in your .gwt.xml

-- TO GWT STEERING COMMITTEE --

please create an independent library

with EntryPoint and JsInterop interfaces

so we can remove GWT-User from dependencies

Polymer is cool ! Write the widgets in javascr ipt

DON'T USE WIDGETS, USE POLYMER

2nd

…displays as a table’s row on the browser

The custom HTML element…

<wunit-dice> elem

ent

<wunit-dice> elem

ent

Aspect

<wunit-game> elem

ent

<wunit-game> elem

ent

Aspect

@JsTypeUSE JsInterop

3rd

@JsTypeUSE JsInterop

3rd

* Note: this WUnit prototype has used the OLD JsInterop annotations

HTM

L H

OST

PAG

E

LINK FROM GWT TO HOST PAGE

LINK FROM GWT TO HOST PAGE

Fail! I had to use JSNI (but it is limited to invoking query selector from Java, and it can be rewritten with the new JsInterop)

OUTPUT FROM JAVA TO POLYMER ELEMENTS

VIEW OUTPUT

Polymer

OUTPUT FROM JAVA TO POLYMER ELEMENTS

VIEW OUTPUT

Polymer

INPUT FROM POLYMER ELEMENTS TO JAVA

Polymer

VIEW INPUT

INPUT FROM POLYMER ELEMENTS TO JAVA

Polymer

VIEW INPUT

DON'T USE IDE PLUGINS 4th

Unfortunately this so lut ion does not works standalone…

I 've hacked extensively the CodeServer

*

Unfortunately this so lut ion does not works standalone…

I 've hacked extensively the CodeServer

HACKS-HACKS-HACKS*

<add-linker name="sso" />

FOCUS: SSO LINKER

<add-linker name="sso" />

FOCUS: SSO LINKER

-- TO GWT STEERING COMMITTEE --

please make Code Server more modular and reusable so we

can use it this approach without hacks

This problem is not solved yet (WUnit don't uses c l ient-server communicat ion)

Work in progress It would be poss ible to implement a c lean approach if GWT was support ing GSON or

if the javaemul was support ing (a more r ich subset of) Java Ref lect ion

DON'T USE GWT RPC5th

-- TO GWT STEERING COMMITTEE --

please create an independent and modular library

with the javaemul, so it can be extended in a clean way

CONCLUSIONS:

How much GWT-User have we used in WUnit?

How much GWT-User have we used in WUnit?

Instrument for

coverage

How much GWT-User have we used in WUnit?

Compile, including

gwt:compile

How much GWT-User have we used in WUnit?

Execute JettyEmbeddedServer

(including Code Server)

How much GWT-User have we used in WUnit?

* Open and run the app (to trigger Code Server compilation)

How much GWT-User have we used in WUnit?

Generate coverage

report

COVERAGE REPORT WUNIT (GWT Compilation and Code Server execution)

+ SUPER SOURCES

+ SUPER SOURCES

J2CL ?

FUTURE:

Maven archetype or Template for this approach

https ://github.com/codejuicer/gwt-s l immize

(release after some c lean up and off ic ia l gwt 2.8 .0)

Career Website: https ://www.thalesgroup.com/en/homepage/careers

Jobs info: cv.r isorseumane@thalesgroup.com

INTERESTED WORKING IN MY TEAM?

THANKS

top related