Upload
javadayua
View
157
Download
2
Embed Size (px)
Citation preview
Intro | History | Goal | Analysis | Summary | ?PainSoftware
Web-applicationI’ve always dreamt
of@JavaDay Lviv
2015
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
Prehistoric Era [...-1995]• Static content only• Interaction without server:
ImpossibleUnthinkable
• Server-side HTML adjustments
Intro | History | Goal | Analysis | Summary | ?PainSoftware
Intro | History | Goal | Analysis | Summary | ?PainSoftware
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
Intro | History | Goal | Analysis | Summary | ?PainSoftware
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
Intro | History | Goal | Analysis | Summary | ?PainSoftware
Modern Era [2010-...]• Internet of Things• Big Data• Cloud Computing• ???
Intro | History | Goal | Analysis | Summary | ?PainSoftware
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/
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
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
Idea
UI
Business Logic
Protocol
Business Logic
Data Storage
Intro | History | Goal | Analysis | Summary | ?PainSoftware
Client(dynamic)
Server(stability)
ClientIntro | History | Goal | Analysis | Summary | ?PainSoftware
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;
});}
ServerIntro | History | Goal | Analysis | Summary | ?PainSoftware
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)}
}}
Business Needs• Integration with anything• High availability• Data is the TOP priority• Client’s satisfaction
Intro | History | Goal | Analysis | Summary | ?PainSoftware
Technical Needs• Scalability• Security• Testability• “Otherity”
Intro | History | Goal | Analysis | Summary | ?PainSoftware
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
…We DesignIntro | History | Goal | Analysis | Summary | ?PainSoftware
…We ImagineIntro | History | Goal | Analysis | Summary | ?PainSoftware
…We BuildIntro | History | Goal | Analysis | Summary | ?PainSoftware
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
…Of CourseIntro | History | Goal | Analysis | Summary | ?PainSoftware
…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() { … }
…Safe CookiesIntro | History | Goal | Analysis | Summary | ?PainSoftware
…Strong PasswordIntro | History | Goal | Analysis | Summary | ?PainSoftware
…$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}
Intro | History | Goal | Analysis | Summary | ?PainSoftware
Testability• Server side:
UnitIntegrationContract[optional] Load & Performance
• Client side: UnitIntegrationContract[optional] Browser & Sanity
Intro | History | Goal | Analysis | Summary | ?PainSoftware
…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); });});
Responsibility• Client:
ResponsiveUser-friendlyPretty
• Server:ScalableFail-proofRedundant
Intro | History | Goal | Analysis | Summary | ?PainSoftware
Traffic• Reduce useless to none• De-increase useful:
Increase volumeDecrease size
Intro | History | Goal | Analysis | Summary | ?PainSoftware
Optimization• Client
CachingPre-fetchingIncremental updates
• Server: CachingPre-fetchingIncremental updates
Intro | History | Goal | Analysis | Summary | ?PainSoftware
Encapsulation• Both parties can have their own secrets
Intro | History | Goal | Analysis | Summary | ?PainSoftware
Polygamy• Is it moral if a client has many servers and vice versa?
Intro | History | Goal | Analysis | Summary | ?PainSoftware
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
QuestionsIntro | History | Goal | Analysis | Summary | ?PainSoftware