Slide 1

Slide 1 text

5 pillars of a successful Java Web application Eder Ignatowicz Sr. Software Engineer @ Red Hat

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Which backend architecture?

Slide 4

Slide 4 text

Java 9 modular, Reactive, Microservices, Vert.x Drools, Spring Boot, Zookeeper, Spark

Slide 5

Slide 5 text

And on the front-end?

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Javascript Development is complex

Slide 11

Slide 11 text

Web Javascript development is complex

Slide 12

Slide 12 text

Web development will stay complex

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Which web stack?

Slide 19

Slide 19 text

Which web architecture is most doable for this problem?

Slide 20

Slide 20 text

5 pillars: Large scale application Full stack Developers UX Integration 5~10 years Life-Span Interoperability

Slide 21

Slide 21 text

5 pillars: Large scale application Full stack Developers UX Integration 5~10 years life-span Interoperability

Slide 22

Slide 22 text

Large Scale Application 1mi+ lines of web code 5 projects ~150 subprojects ~30 devs Code base of 7+ years

Slide 23

Slide 23 text

Large Scale Application Static Typing

Slide 24

Slide 24 text

Large Scale Application Refactoring

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Large Scale Application JS Transpilers

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

.java javac .class

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

GWT <3

Slide 35

Slide 35 text

GWT The Good Parts

Slide 36

Slide 36 text

GWT GOOD PARTS Java to JavaScript

Slide 37

Slide 37 text

GWT GOOD PARTS java.* emulation

Slide 38

Slide 38 text

GWT GOOD PARTS DOM APIs

Slide 39

Slide 39 text

GWT GOOD PARTS Java 8 “client side"

Slide 40

Slide 40 text

Java 8 List myList = Arrays.asList("Java7", “Java8", "Java6", "Kotlin"); myList .stream() .filter(s -> s.startsWith("J")) .map(String::toUpperCase) .sorted() .forEach(Console::log); Prints: JAVA6 JAVA7 JAVA8

Slide 41

Slide 41 text

GWT GOOD PARTS Dev Tools

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

GWT GOOD PARTS JS Interop

Slide 44

Slide 44 text

JS INTEROP - CONSUME Java @JsType(isNative = true) public abstract class JQuery { @JsMethod(namespace=GLOBAL) public native static JQuery $(String selector); public native JQuery css(String prop, String val); public native JQuery attr(String name, String val); } Java import static jquery.JQuery.$; // ... $("ul > li").css("color", "red").attr("data-level", "first");

Slide 45

Slide 45 text

JS INTEROP - EXPOSE Java package foo; @JsType public class Dora { public boolean late = true; public Dora() {} public String auAu() { return "Hello QCon!";} } JavaScript var dora = new foo.Dora(); if (dora.late) { alert(dora.auAu()); }

Slide 46

Slide 46 text

Large Scale Application Refactoring

Slide 47

Slide 47 text

5 pillars: Large scale application Full stack Developers UX Integration 5~10 years life-span Interoperability

Slide 48

Slide 48 text

Devs Full Stack “End-to-end” developers

Slide 49

Slide 49 text

Devs Full Stack Shared Programming Model

Slide 50

Slide 50 text

Devs Full Stack “Java EE” in browser

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

ERRAI CDI on Browser

Slide 53

Slide 53 text

@Dependent public class ProjectsView { @Inject Document document; @Inject @DataField( "projects-view" ) Div view; @Inject @DataField( "new-project" ) Button newProject; @Inject @DataField( "projects-list" ) UnorderedList projectsList; @Inject Instance projects; CDI NO BROWSER

Slide 54

Slide 54 text

if (!filter.doFilter(event)) { if (event.kind().equals(StandardWatchEventKind.ENTRY_ADD)) { resourceAddedEvent.fire(buildEvent(ResourceAddedEvent.class, event).getK2()); } … }

Slide 55

Slide 55 text

public void onNewFile(@Observes ResourceAddedEvent event) { Window.alert( "ResourceAddedEvent:" + event.getPath().toURI() + " ['" + event.getMessage() + “‘]"); }

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

Server Browser Browser Browser Browser Long Polling Web Sockets SSE ERRAI BUS

Slide 58

Slide 58 text

Devs Full Stack Shared Programming Model

Slide 59

Slide 59 text

5 pillars: Large scale application Full stack Developers UX Integration 5~10 years life-span Interoperability

Slide 60

Slide 60 text

Pizza Types

    <% for ( Pizza pizza : pizzaTypes ) { %>
  • <%=pizza.getName()%> <%=pizza.getPrice()%>$
  • <% } %>

Size

  • Small Medium ( + 2$ ) Large ( + 3$ )

Extra Toppings

<% for ( int j = 0; j < 3; j++ ) { %>
    <% for ( int i = sliceSize * j; i < ( j + 1 ) * sliceSize; i++ ) { %>
  • <%=pizzaToppings.get( i )%>
  • <% } if ( j == 0 && remainder > 0 ) { %>
  • <%=pizzaToppings.get( pizzaToppings.size() - 2 )
  • <% } else if ( j == 1 && remainder > 1 ) { %>
  • <%=pizzaToppings.get( pizzaToppings.size() - 1 )%>
  • <% } %>
<% } %>

Each extra topping is 0.65$

...

Slide 61

Slide 61 text

{{title}}

My favorite hero is: {{myHero}}

Heroes:

  • {{ hero }}

Slide 62

Slide 62 text

New Project

Slide 63

Slide 63 text

@Dependent @Templated public class ProjectsView { @Inject @DataField( "projects-view" ) Div view; @Inject @DataField( "new-project" ) Button newProject; @Inject @DataField( "projects-list" ) UnorderedList projectsList; } ERRAI UI

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Welcome to BPM Suite

Business Process Management (BPM) Suite offers a set of flexible, process management tools that support the way you need to work. Select a BPM tool below to get started.

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

UX Integration Leave the HTML/CSS in peace

Slide 68

Slide 68 text

5 pillars: Large scale application Full stack Developers UX Integration 5~10 years life-span Interoperability

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

Architecture Hexagonal Architecture - Alistair Cockburn Onion Architecture - Jeffrey Palermo DCI - James Coplien e Trygve Reenskaug. BCE - Ivar Jacobson Clean Architecture - Robert C. Martin

Slide 71

Slide 71 text

Principles Not coupled to Frameworks Testable Not coupled with UI technology Not coupled with Database Independent of another systems

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

"Architecture is about intent. We have made it about frameworks and details” Robert C. Martin

Slide 74

Slide 74 text

APPFORMER VFS Use Cases VFS API Regular FS Clustering GIT FS

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

Which web framework should I use?

Slide 77

Slide 77 text

Which JS framework?

Slide 78

Slide 78 text

JS framework choice Years 1 2 3 4 5 6 First Release Danger 0

Slide 79

Slide 79 text

What’s next for Angular 1.x? "In all honesty, no one really knows what will happen" https://toddmotto.com/future-of-angular-1-x

Slide 80

Slide 80 text

1 2 3 4 5 6 Years Deliver JS Framework Choice Learning Curve Project Canceled or new version is incompatible Rewrite on the new JS framework Learning Curve Project Canceled or new version is incompatible Rewrite on the new JS framework Learning Curve

Slide 81

Slide 81 text

"A good architecture allows volatile decisions to be easily changed” Robert C. Martin

Slide 82

Slide 82 text

What if I dealt with the volatility of JS frameworks as a fact?

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

Programming Model Components: - Screen - Editors - Perspectives - Popups

Slide 86

Slide 86 text

Programming Model LifeCycle: - OnStart - OnSave - IsDirty - OnClose - OnFocus - OnLostFocus - OnMayClose - OnReveal

Slide 87

Slide 87 text

Perspective Editor Screen Screen

Slide 88

Slide 88 text

Contract Based Screen -> Interface WorkbenchScreenActivity Editor -> Interface WorkbenchEditorActivity Perspective -> Interface PerspectiveActivity

Slide 89

Slide 89 text

Perspectives Appformer Lookup Perspective ERRAI CDI BEAN MANAGER Scan all Perspective Activity Implementations GWT Perspective Adapter OLD GWT WIDGET ERRAI UI Perspective Adapter Plain HTML Errai UI

Slide 90

Slide 90 text

7 years old code with “old school” GWT

Slide 91

Slide 91 text

HTML 5 canvas fresh code

Slide 92

Slide 92 text

5~10 years life-span The Web architecture should be treated with the same respect as you treat your backend.

Slide 93

Slide 93 text

5 pillars: Large scale application Full stack Developers UX Integration 5~10 years life-span Interoperability

Slide 94

Slide 94 text

@WorkbenchPerspective(identifier = "HomePerspective", isDefault = true) @Templated public class HomePerspective implements IsElement { @Inject @DataField @WorkbenchPanel(parts = "MoodScreen?uber=fire&uber1=fire1") Div moodScreen; @Inject @DataField @WorkbenchPanel(parts = "HomeScreen?uber=fire") Div homeScreen; @Inject @DataField @WorkbenchPanel(parts = "AnotherScreen") Div anotherScreen; } @JsType public interface PerspectiveActivity{ PerspectiveDefinition getDefaultPerspectiveLayout(); @Override default String getName() { return getDefaultPerspectiveLayout().getName(); } boolean isDefault(); Menus getMenus(); ToolBar getToolBar(); }

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

function TodoCtrl($scope) { $scope.placeText = "MiscellaneousFeatures"; $scope.todos = [ {text: 'learn angular', done: true}, {text: 'build an angular app', done: false} ]; $scope.addTodo = function () { $scope.todos.push({text: $scope.todoText, done: false}); $scope.todoText = ''; }; $scope.remaining = function () { var count = 0; angular.forEach($scope.todos, function (todo) { count += todo.done ? 0 : 1; }); return count; }; $scope.archive = function () { var oldTodos = $scope.todos; $scope.todos = []; angular.forEach(oldTodos, function (todo) { if (!todo.done) { $scope.todos.push(todo); } }); }; $scope["goto"] = function () { $goToPlace($scope.placeText); }; }

{{remaining()}} of {{todos.length}} remaining [ archive ]

Todos

  • {{todo.text}}
$registerPlugin({ id: "my_angular_js", type: "angularjs", templateUrl: "angular.sample.html", title: function () { return "angular " + Math.floor(Math.random() * 10); }, on_close: function () { alert("this is a pure JS alert!"); } });

Slide 97

Slide 97 text

Perspectives Appformer Lookup Perspective ERRAI CDI BEAN MANAGER Scan all Perspective Activity Implementations GWT Perspective Adapter OLD GWT WIDGET ERRAI UI Perspective Adapter Plain HTML Errai UI Angular Perspective Adapter Angular native Perspective Any JS Perspective Adapter Any JS Framework

Slide 98

Slide 98 text

Angular JS Screen

Slide 99

Slide 99 text

Creating Components in Runtime

Slide 100

Slide 100 text

No content

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

5 pillars: Large scale application Full stack Developers UX Integration 5~10 years life-span Interoperability

Slide 103

Slide 103 text

Web development is complex

Slide 104

Slide 104 text

Web applications are important pieces of our architecture

Slide 105

Slide 105 text

Principles Not coupled to Frameworks Testable Not coupled with UI technology Not coupled with Database Independent of another systems

Slide 106

Slide 106 text

Software architecture is trade-offs exercise

Slide 107

Slide 107 text

5 pillars: Large scale application Full stack Developers UX Integration 5~10 years life-span Interoperability

Slide 108

Slide 108 text

Eder Ignatowicz @ederign http://bit.ly/5-pillars-web