web application i have always dreamt of (lviv)

39
Intro | History | Goal | Analysis | Summary | ? PainSoftware Web-application I’ve always dreamt of @JavaDay Lviv 2015

Upload: victorcr

Post on 30-Jul-2015

141 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Web application I have always dreamt of (Lviv)

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Web-applicationI’ve always dreamt

of@JavaDay Lviv

2015

Page 2: Web application I have always dreamt of (Lviv)

Victor Polischuk

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Experience Summary

Programming 26

Overall 32

Java 11

Web 11

Legacy 11

Professional 13

Has something to share

@alkovictorvictor-cr

Page 3: Web application I have always dreamt of (Lviv)

Prehistoric Era [...-1995]

• Static content only• Interaction without server:

ImpossibleUnthinkable

• Server-side HTML adjustments

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 4: Web application I have always dreamt of (Lviv)

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 5: Web application I have always dreamt of (Lviv)

Medieval Era [1995-2005]

• Static content mostly• Interaction without server: cached resources• Server-side HTML+CSS+JS adjustments• Frames as asynchronous data loading• Birth of:

Servlet APIJavaScriptDHTML conceptFlashBrowser-compatibility hellRFC1925

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 6: Web application I have always dreamt of (Lviv)

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 7: Web application I have always dreamt of (Lviv)

Renaissance Era [2005-2010]

• Static content with dynamic “whistles”• Interaction without server: simple functions• Server-side HTML+CSS+JS adjustments• Rising popularity of Rich Internet Applications• Birth of:

jQueryDOJOAJAX and Comet

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 8: Web application I have always dreamt of (Lviv)

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 9: Web application I have always dreamt of (Lviv)

Modern Era [2010-...]

• Internet of Things• Big Data• Cloud Computing• ???

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 10: Web application I have always dreamt of (Lviv)

Overview

Intro | History | Goal | Analysis | Summary | ?PainSoftware

http://zeroturnaround.com/rebellabs/top-4-java-web-frameworks-revealed-real-life-usage-data-of-spring-mvc-vaadin-gwt-and-jsf/

Page 11: Web application I have always dreamt of (Lviv)

Business Needs

• Integration with anything:MobileMainframeCoffee machine

• High availability: Hard to predict clients behavior

• Data is the TOP priority:We make money out of it

• Client’s satisfaction:Should be happier than those of our competitors

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 12: Web application I have always dreamt of (Lviv)

Idea

• “All problems in computer science can be solved by another level of indirection” © David Wheeler

• “Do One Thing and Do It Well” © Unix community

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 13: Web application I have always dreamt of (Lviv)

Idea

UI

Business Logic

Protocol

Business Logic

Data Storage

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Client(dynamic)

Server(stability)

Page 14: Web application I have always dreamt of (Lviv)

Client

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 15: Web application I have always dreamt of (Lviv)

Client

Intro | History | Goal | Analysis | Summary | ?PainSoftware

$http.get(“/rs/stat/” + key).success(function(data) {self.statistics.records = data;

}).error(function(data, statusCode) {self.errorContent = data;

if (statusCode === 404 || statusCode >= 500) {self.unavailable = true;self.timerId = setInterval(self.ping, 1000);

}});

self.ping = function() {$http.get(“/rs/ping”).success(function() {

clearInterval(self.timerId);self.unavailable = false;

});}

Page 16: Web application I have always dreamt of (Lviv)

Server

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 17: Web application I have always dreamt of (Lviv)

Server

Intro | History | Goal | Analysis | Summary | ?PainSoftware

def receive = {case GetNumber(id) => sender ! getNumber(id)case GetStat(key) => sender ! getStatistics(key)case AddVote(entity) => sender ! doVote(entity)case AddClient(ip) => sender ! createClient(ip.value)case entity: AddProposal => sender ! createNumber(entity)case entity: UpdateProposal => sender !

updateNumber(entity)}

val route = path(“ping”) {

ctx => ctx.complete(“PONG”)} ~ (path(“stat” / JavaUUID) & get) {

key => rejectEmptyResponse {handlePerRequest {

GetStat(key)}

}}

Page 18: Web application I have always dreamt of (Lviv)

Business Needs

• Integration with anything• High availability• Data is the TOP priority• Client’s satisfaction

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 19: Web application I have always dreamt of (Lviv)

Technical Needs

• Scalability• Security• Testability• “Otherity”

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 20: Web application I have always dreamt of (Lviv)

Scalability

• Server is just a bunch of endpoints• Independent client• State

Client needs itServer doesn’t

• SLAWay to Nine-NinesYou do not want to lose clients, right?

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 21: Web application I have always dreamt of (Lviv)

…We Design

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 22: Web application I have always dreamt of (Lviv)

…We Imagine

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 23: Web application I have always dreamt of (Lviv)

…We Build

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 24: Web application I have always dreamt of (Lviv)

Security

• Do you need it on each request?• Do you know how it works?• Do you think it is secure?

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 25: Web application I have always dreamt of (Lviv)

…Of Course

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 26: Web application I have always dreamt of (Lviv)

…Safe JSF

Intro | History | Goal | Analysis | Summary | ?PainSoftware

<h:form> <h:selectOneMenu value="#{control.selectedServer}"> <f:selectItems value="#{control.availableServers}"/> </h:selectOneMenu>

<h:commandButton value=“Reboot" action=“#{control.reboot}" /> </h:form>

@ManagedBean(name=“control")@ViewScopedpublic class ControlBean implements Serializable {… private String selectedServer; private Map<String, String> availableServers;… public String reboot() { … }

Page 27: Web application I have always dreamt of (Lviv)

…Safe Cookies

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 28: Web application I have always dreamt of (Lviv)

…Strong Password

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 29: Web application I have always dreamt of (Lviv)

…$5000 bug

Intro | History | Goal | Analysis | Summary | ?PainSoftware

POST https://www.youtube.com/live_events_edit_status_ajax?action_delete_live_event=1event_id: ANY_VIDEO_IDsession_token: YOUR_TOKEN

{ "success": 1}

Page 30: Web application I have always dreamt of (Lviv)

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 31: Web application I have always dreamt of (Lviv)

Testability

• Server side: UnitIntegrationContract[optional] Load & Performance

• Client side: UnitIntegrationContract[optional] Browser & Sanity

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 32: Web application I have always dreamt of (Lviv)

…Client

Intro | History | Goal | Analysis | Summary | ?PainSoftware

describe("A suite is just a function", function() { var a; it("and so is a spec", function() { a = true; expect(a).toBe(true); });});

Page 33: Web application I have always dreamt of (Lviv)

Responsibility

• Client:ResponsiveUser-friendlyPretty

• Server:ScalableFail-proofRedundant

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 34: Web application I have always dreamt of (Lviv)

Traffic

• Reduce useless to none• De-increase useful:

Increase volumeDecrease size

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 35: Web application I have always dreamt of (Lviv)

Optimization

• ClientCachingPre-fetchingIncremental updates

• Server: CachingPre-fetchingIncremental updates

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 36: Web application I have always dreamt of (Lviv)

Encapsulation

• Both parties can have their own secrets

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 37: Web application I have always dreamt of (Lviv)

Polygamy

• Is it moral if a client has many servers and vice versa?

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 38: Web application I have always dreamt of (Lviv)

Summary

• Effectiveness: you have one job• Security: you are limiting interaction to minimum• Testability: test JSF page, I dare you!• State: -less server, -ful client• Elasticity/scalability: your data volume is growing• Network optimizations: you know what you send• Local optimizations: you know what you do• Many-to-many connections• SLA

Intro | History | Goal | Analysis | Summary | ?PainSoftware

Page 39: Web application I have always dreamt of (Lviv)

Questions

Intro | History | Goal | Analysis | Summary | ?PainSoftware