Share
Embed
Transcript
76 slides
-
Wir lösen das – persönlich! Resource-oriented Client Architecture Holger Kraus
| Stefan Tilkov | innoQ -
© 2012 innoQ Deutschland GmbH URIs Identifies Resources http://example.com/orders?year=2008 http://example.com/customers/1234
http://example.com/orders/2007/10/776654 http://example.com/products/4554 http://example.com/processes/sal-increase-234 -
© 2012 innoQ Deutschland GmbH Representations in different Formats XML
HTML XHTML JSON YAML Plain Text PDF Binary -
© 2012 innoQ Deutschland GmbH Customer Order Delivery Product CustomerList
ProductCatalog Rating «interface» Resource -
© 2012 innoQ Deutschland GmbH Customer Order Delivery Product CustomerList
ProductCatalog Rating «interface» Resource CustomerView OrderEntryForm ProductMaintenanceForm -
© 2011 innoQ Deutschland GmbH Data Replication Backend Integration Frontend
Integration Integration Options Data Logic UI Data Logic UI -
© 2012 innoQ Deutschland GmbH Browser HTML Page Backend 1
UI 1 Frontend Server UI 2 Server-side integration Backend 2 Examples: ESI-Caches SSI Portal Server -
© 2012 innoQ Deutschland GmbH Browser HTML Page Backend 1
UI 1 UI 2 Client-side integration Backend 2 Examples: AJAX Proprietary Frameworks -
© 2012 innoQ Deutschland GmbH Browser HTML Page 1 Links
Backend 1 Backend 2 HTML Page 2 Asset Server CSS, JS, IMG, ... <a href=2 /> -
© 2012 innoQ Deutschland GmbH “But what about stateful Web
applications?” -
© 2012 innoQ Deutschland GmbH Browser Server HTML Page Label
Label Label Label Label Label Label Label Submit -
© 2012 innoQ Deutschland GmbH Browser Server Label Label Label
Next Label Label Label Next Label Label Finish Session State -
© 2012 innoQ Deutschland GmbH Browser Server Label Label Label
Next Label Label Label Next Label Label Finish HTML Page Label Label Label Label Label Label Label Label Submit Client State -
© 2012 innoQ Deutschland GmbH JavaScript WTFs alert(111111111111111111111); // alerts
111111111111111110000 ("foo" + + "bar") === "fooNaN" // true // Reason: "foo" + (+"bar") === "foo" + NaN typeof NaN === 'number' // true Infinity === 1/0 // true 0.1 + 0.2 === 0.3 // false [] + [] // "" [] + {} // [object Object] {} + [] // 0 {} + {} // NaN https://www.destroyallsoftware.com/talks/wat http://oreilly.com/javascript/excerpts/javascript-good-parts/awful-parts.html http://oreilly.com/javascript/excerpts/javascript-good-parts/bad-parts.html http://wtfjs.com/ -
© 2012 innoQ Deutschland GmbH 5.1.7 Code-On-Demand The final addition
to our constraint set for REST comes from the code-on-demand style of Section 3.5.3 (Figure 5-8). REST allows client functionality to be extended by downloading and executing code in the form of applets or scripts. This simplifies clients by reducing the number of features required to be pre- implemented. Allowing features to be downloaded after deployment improves system extensibility. However, it also reduces visibility, and thus is only an optional constraint within REST. http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_1_7 -
© 2012 innoQ Deutschland GmbH From server to client Server-side
Components ROCA Single Page Apps Flash Silverlight Applets ... Most Web Apps Server Client -
© 2012 innoQ Deutschland GmbH Use URIs to identify a
single meaningful concept -
© 2012 innoQ Deutschland GmbH Browser HTML Page Main Content
Header, Main Navigation Sidebar Sidebar Footer -
© 2012 innoQ Deutschland GmbH Browser HTML Page Main Content
Header, Main Navigation Footer Sidebar Content Sidebar Content -
© 2012 innoQ Deutschland GmbH Browser HTML Page Main Content
1 Header, Main Navigation Footer Main Content 2 ✗ -
© 2012 innoQ Deutschland GmbH Browser HTML Page Main Content
1 Header, Main Navigation Footer HTML Page Other Main Content Header, Main Navigation Footer -
© 2012 innoQ Deutschland GmbH Multiple tabs & windows Bookmarks
Back/Forward/Refresh Personalization Menus -
© 2012 innoQ Deutschland GmbH Don’t trust your clients RESTful
APIs for free Non-browser clients (e.g. Google Crawler) -
© 2012 innoQ Deutschland GmbH Minimal load times API usage
Accessibility Self-descriptiveness Readability Reusability -
© 2012 innoQ Deutschland GmbH $("a.whatever").click(function() { doSomething(this.href); }); +
<a href="/some-resource" class="whatever"> Some Link </a> -
© 2012 innoQ Deutschland GmbH <div id="tabs"> <ul> <li><a href="#tabs-1">Nunc
tincidunt</a></li> <li><a href="#tabs-2">Proin dolor</a></li> <li><a href="#tabs-3">Aenean lacinia</a></li> </ul> <div id="tabs-1"> <p>Proin elit arcu, rutrum commodo, vehicula ...</p> </div> <div id="tabs-2"> <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio ...</p> </div> <div id="tabs-3"> <p>Mauris eleifend est et turpis. Duis id erat ...</p> </div> $("#tabs").tabs(); + -
© 2012 innoQ Deutschland GmbH <a href="javascript:doSomething(4711);"> Some Link </a>
<a href="javascript:doSomething(4712);"> Some other Link </a> -
© 2012 innoQ Deutschland GmbH <a href="/some-resource" class="whatever" data-param1="xyz"> Some
Link </a> $("a.whatever").click(function() { doSomething(this.href, $(this).data("param1")); }); + -
© 2012 innoQ Deutschland GmbH JS component JS glue code
HTML Events Methods Component 2 Component 3 ... Layout/CSS styles styles Server / Backend Ajax initializes Base Markup responds with -
© 2012 innoQ Deutschland GmbH Ensure you’re on the Web,
not tunneling through it -
© 2012 innoQ Deutschland GmbH You can build fancy web
apps unobtrusively -
© 2012 innoQ Deutschland GmbH Thank you! Q&A Stefan Tilkov
[email protected] @stilkov Phone: +49 170 471 2625 innoQ Deutschland GmbH http://www.innoq.com Krischerstr. 100 40789 Monheim am Rhein Germany Phone: +49 2173 3366-0 innoQ Schweiz GmbH [email protected] Gewerbestr. 11 CH-6330 Cham Switzerland Phone: +41 41 743 0116 Holger Kraus [email protected] Phone: +49 151 42656093 -
© 2012 innoQ Deutschland GmbH How much HTTP would you
like with that? -
© 2012 innoQ Deutschland GmbH Request/Response-oriented Struts Play Grails Rails
ASP.NET MVC (Native) PHP Django Spring MVC -
© 2012 innoQ Deutschland GmbH Rich-client Applets JavaFX GWT Silverlight
Flash/Flex Echo ZK Meteor Backbone.js -
© 2012 innoQ Deutschland GmbH Linkable and “pretty” URIs GET/POST
differentiation Support for caching Full control over HTML 1 Resource, n Views Request/Response Frameworks -
© 2012 innoQ Deutschland GmbH # “When a URI reference
is used to perform a retrieval action on the identified resource, the optional fragment identifier, separated from the URI by a crosshatch (“#”) character, consists of additional reference information to be interpreted by the user agent after the retrieval action has been successfully completed. As such, it is not part of a URI, but is often used in conjunction with a URI.” URI Specification, August 1998 -
© 2012 innoQ Deutschland GmbH # The fragment identifier component
of a URI allows indirect identification of a secondary resource by reference to a primary resource and additional identifying information. The identified secondary resource may be some portion or subset of the primary resource, some view on representations of the primary resource, or some other resource defined or described by those representations. URI Specification, January 2005 -
© 2012 innoQ Deutschland GmbH Complex Inaccessible Brittle Invisible to
search engines (#) # and #! Downsides