Web-application I’ve always dreamt of (Kharkiv)

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

Transcript of Web-application I’ve always dreamt of (Kharkiv)

Page 1: Web-application I’ve always dreamt of (Kharkiv)

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

Web-applicationI’ve always dreamt

of@JavaDay Kharkiv

2015

Page 2: Web-application I’ve always dreamt of (Kharkiv)

Victor PolischukIntro | 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’ve always dreamt of (Kharkiv)

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’ve always dreamt of (Kharkiv)

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

Page 5: Web-application I’ve always dreamt of (Kharkiv)

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’ve always dreamt of (Kharkiv)

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

Page 7: Web-application I’ve always dreamt of (Kharkiv)

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’ve always dreamt of (Kharkiv)

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

Page 9: Web-application I’ve always dreamt of (Kharkiv)

Modern Era [2010-...]• Internet of Things• Big Data• Cloud Computing• ???

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

Page 10: Web-application I’ve always dreamt of (Kharkiv)

OverviewIntro | 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’ve always dreamt of (Kharkiv)

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’ve always dreamt of (Kharkiv)

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’ve always dreamt of (Kharkiv)

Idea

UI

Business Logic

Protocol

Business Logic

Data Storage

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

Client(dynamic)

Server(stability)

Page 14: Web-application I’ve always dreamt of (Kharkiv)

ClientIntro | History | Goal | Analysis | Summary | ?PainSoftware

Page 15: Web-application I’ve always dreamt of (Kharkiv)

ClientIntro | 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’ve always dreamt of (Kharkiv)

ServerIntro | History | Goal | Analysis | Summary | ?PainSoftware

Page 17: Web-application I’ve always dreamt of (Kharkiv)

ServerIntro | 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’ve always dreamt of (Kharkiv)

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’ve always dreamt of (Kharkiv)

Technical Needs• Scalability• Security• Testability• “Otherity”

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

Page 20: Web-application I’ve always dreamt of (Kharkiv)

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’ve always dreamt of (Kharkiv)

…We DesignIntro | History | Goal | Analysis | Summary | ?PainSoftware

Page 22: Web-application I’ve always dreamt of (Kharkiv)

…We ImagineIntro | History | Goal | Analysis | Summary | ?PainSoftware

Page 23: Web-application I’ve always dreamt of (Kharkiv)

…We BuildIntro | History | Goal | Analysis | Summary | ?PainSoftware

Page 24: Web-application I’ve always dreamt of (Kharkiv)

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’ve always dreamt of (Kharkiv)

…Of CourseIntro | History | Goal | Analysis | Summary | ?PainSoftware

Page 26: Web-application I’ve always dreamt of (Kharkiv)

…Safe JSFIntro | 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’ve always dreamt of (Kharkiv)

…Safe CookiesIntro | History | Goal | Analysis | Summary | ?PainSoftware

Page 28: Web-application I’ve always dreamt of (Kharkiv)

…Strong PasswordIntro | History | Goal | Analysis | Summary | ?PainSoftware

Page 29: Web-application I’ve always dreamt of (Kharkiv)

…$5000 bugIntro | 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’ve always dreamt of (Kharkiv)

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

{“success”:1}

Page 31: Web-application I’ve always dreamt of (Kharkiv)

Testability• Server side:

UnitIntegrationContract[optional] Load & Performance

• Client side: UnitIntegrationContract[optional] Browser & Sanity

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

Page 32: Web-application I’ve always dreamt of (Kharkiv)

…ClientIntro | 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’ve always dreamt of (Kharkiv)

Responsibility• Client:

ResponsiveUser-friendlyPretty

• Server:ScalableFail-proofRedundant

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

Page 34: Web-application I’ve always dreamt of (Kharkiv)

Traffic• Reduce useless to none• De-increase useful:

Increase volumeDecrease size

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

Page 35: Web-application I’ve always dreamt of (Kharkiv)

Optimization• Client

CachingPre-fetchingIncremental updates

• Server: CachingPre-fetchingIncremental updates

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

Page 36: Web-application I’ve always dreamt of (Kharkiv)

Encapsulation• Both parties can have their own secrets

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

Page 37: Web-application I’ve always dreamt of (Kharkiv)

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

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

Page 38: Web-application I’ve always dreamt of (Kharkiv)

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’ve always dreamt of (Kharkiv)

QuestionsIntro | History | Goal | Analysis | Summary | ?PainSoftware