程序设计模式
(25)
Programming Patterns (25)
Programming Patterns (25)
- RESTful Service Expose web services according to RESTful principles.
- RPC Service(远端程序调用) Expose web services as Remote Procedural Calls (RPCs).
- HTML Response(直接生成HTML代码片断返回) Have the server generate HTML snippets to be displayed in the browser.
- Semantic Response(以特定语义的数据封装方式返回) Have the server respond with abstract, semantic, data.
- Plain-Text Message (Text格式传递)Pass simple messages between server and browser in plain-text format.
- XML Message (XML格式传递)Pass messages between server and browser in XML format.
- JSON Message Pass messages between server and browser in Javascript Object Notation (JSON) format.
浏览器
-
服务器对话
Browser-Server Dialogue
Browser-Server Dialogue
- Call Tracking Accommodate busy user behaviour by allocating a new XMLHtpRequest object for each request. See Richard Schwartz's blog entry.Note: Pending some rewrite to take into account request-locking etc.
- Distributed Events Keep objects synchronised with an event mechanism.
- On-Demand Javascript (立即响应JS)Download Javascript as and when required, instead of downloading it all on page load.
DOM Population
- XML Data Island(XML数据岛) Retain XML responses as "XML Data Islands", nodes within the HTML DOM.
- Browser-Side XSLT(浏览器端XSLT) Apply XSLT to convert XML Messages into XHTML.
- Browser-Side Templating(浏览器端模板) Produce browser-side templates and call on a suitable browser-side framework to render them as HTML.
性能优化
Performance Optimisation
Performance Optimisation
- Fat Client (创建富客户端)Create a rich, browser-based, client by peforming remote calls only when there is no way to achieve the same effect in the browser.
- Browser-Side Cache (浏览器端缓存)Maintain a local cache of information.
- Guesstimate(估计值替代服务器端的真实数据读取) Instead of grabbing real data from the server, make a guesstimate that's good enough for most user's needs. ITunes Download Counter, GMail Storage Counter.
- Submission Throttling(提交调节) Instead of submitting upon each Javascript event, retain the data in a local buffer and upload it periodically.
- Explicit Submission(显示提交) Instead of submitting upon each Javascript event, require the user to explicitly request it, e.g. submit upon clicking a button.
- Multi-Stage Download (页面分级下载)Quickly download the page structure with a standard request, then populate it with further requests.
- Predictive Fetch(数据预取) Anticipate likely user actions and pre-load the required data.
扩展
Extension
Extension
- Cross-Domain Proxy (跨域代理)Allow the browser to communicate with other domains by server-based mediation.
- Richer Plugin(更“富”的插件) Make your application "more Ajax than Ajax" with a Richer Plugin.
代码产生与重用
Code Generation and Reuse
Code Generation and Reuse
- Ajax Stub (桩)Use an "Ajax Stub" framework which allows browser scripts to directly invoke server-side operations, without having to worry about the details of XMLHttpRequest and HTTP transfer.
- Server-Side Code Generation(服务端的代码生成) Automatically generate HTML and Javascript from server-side code.
- Cross-Browser Component (跨浏览器组件)Create cross-browser components, allowing programmers to reuse them without regard for browser compatibility.
待续
--3