rob tweed :: ajax and the impact on caché and similar technologies
TRANSCRIPT
![Page 1: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/1.jpg)
Ajax and the Impact on Caché and Similar Technologies
Rob Tweed
M/Gateway Developments Ltd
![Page 2: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/2.jpg)
Ajax: a whole new world!
• Ajax presents a totally different way of considering and developing web applications
• Brings the web much closer to the typical event-driven client-server GUI style of application
![Page 3: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/3.jpg)
What is Ajax?
• A term coined by Jesse James Garrett in 2005 to describe a range of techniques and technologies that were starting to appear widely:– http://adaptivepath.com/publications/essays/archives/000385.php
• Ajax = Asynchronous Javascript and XML• Actually XML not often used at all!
– Broad and vague term that describes a style of application more than a set of technologies
![Page 4: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/4.jpg)
Pioneers of Ajax
• WebLink’s Event Broker– Pre-dated Ajax by some 10 years!
• Many people have been using Ajax-like tricks using hidden frames for many years
![Page 5: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/5.jpg)
Pioneers of Ajax
• Three big stimuli:– XMLHttpRequest object become standard in
all browsers• Initially a Microsoft ActiveX component used for
Outlook Web Access 2000
– Widely available broadband at reasonable cost
– Google Maps and GMail• Created huge interest in the techniques and clearly
demonstrated their power
![Page 6: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/6.jpg)
What distinguishes an Ajax application?
• Not page-oriented, breaks away from:– Fill out a form– Click a button– Page refreshed with another
• To event-oriented - content dynamically changed within a single page– Some Ajax applications are just a single page of
HTML that the user interacts with for hours!– Looks and behaves much more like a typical
client/server VB or Java application
![Page 7: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/7.jpg)
Ajax Key Technologies
• Javascript and Event Handlers• Cascading Style Sheets (CSS)• XMLHttpRequest Object
– “back-channel” built into the browser that allows a Javascript function to communicate externally via HTTP
• Standard HTTP request/response
• Browser’s Document Object Model (DOM)– Dynamic HTML
• JSON (JavaScript Object Notation)
![Page 8: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/8.jpg)
Typical Ajax technique
• Catch an in-browser event:– Standard Javascript event handler
• onClick, onChange, onMouseOver
• Send an asynchronous request via XMLHTTPRequest object
• Use the response to modify part of the page in the browser by manipulating the DOM– Or send and optionally invoke a JavaScript object via
JSON
![Page 9: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/9.jpg)
Browser’s DOM
• When a page of HTML is received by a browser, it is parsed into a DOM
• API methods to manipulate the DOM are implemented in Javascript– document.getElementById(“myField”).parentNode– document.getElementById(“myField”).firstChild
![Page 10: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/10.jpg)
Javascript DOM API
var alertPointer = document.getElementById("ajaxAlert") ;var head = document.getElementsByTagName("head").item(0);alertPointer = document.createElement("script") ;alertPointer.id = "ajaxAlert" ;alertPointer.type = "text/javascript" ;head.appendChild(alertPointer) ;alertPointer.text = "EWD.ajax.errorOn() ;" ;
Example:
![Page 11: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/11.jpg)
DOM Content Replacement
<div id=“myId”>
<h3>
This is some text
</h3>
</div>
Element<div>
Element<h3>
parent
TextThis is some text
firstChild
parent
firstChild
![Page 12: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/12.jpg)
<div id=“myId”>
<h3>
This is some text
</h3>
</div>
Element<div>
Element<h3>
parent
TextThis is some text
firstChild
parent
firstChild
Special HTML DOM property:innerHTML
DOM Content Replacement
![Page 13: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/13.jpg)
<div id=“myId”>
<h3>
This is some text
</h3>
</div>document.getElementById(“myId”).innerHTML
• read/write property
DOM Content Replacement
![Page 14: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/14.jpg)
document.getElementById(“myId”).innerHTML = “<p>Some new text</p>” ;
<div id=“myId”> <h3> This is some text </h3></div>
DOM Content Replacement
![Page 15: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/15.jpg)
document.getElementById(“myId”).innerHTML = “<p>Some new text</p>” ;
<div id=“myId”>
</div>
DOM Content Replacement
![Page 16: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/16.jpg)
document.getElementById(“myId”).innerHTML = “<p>Some new text</p>” ;
<div id=“myId”> <p> Some new text </p></div>
DOM Content Replacement
![Page 17: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/17.jpg)
Browser DOM is active
• As soon as you make a modification to the browser’s DOM, the browser re-renders the page
• By replacing DOM content with markup delivered as page fragments, we can create an interactive experience for the user
• Changes the web event model…
![Page 18: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/18.jpg)
Ajax Event Cycle (EWD)
ContainerPage
Fetchdata
Pre-pageScript
EWD State & Session Management
Caché/ GT.M Server
Front-end technology (WebLink, PHP, CSP etc)
![Page 19: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/19.jpg)
ContainerPage
FetchPage
Fragment
Page Fragment
Fetchdata
Event
Replaces DOM content
Pre-pageScript
Pre-pageScript
EWD State & Session Management
Caché/ GT.M Server
XMLHttpRequest
Ajax Event Cycle (EWD)
![Page 20: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/20.jpg)
ContainerPage
FetchPage
Fragment
Page Fragment
Fetchdata
Event
Replaces DOM content
Pre-pageScript
EWD State & Session Management
Caché/ GT.M Server
Ajax Event Cycle (EWD)
![Page 21: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/21.jpg)
ContainerPage
EWD State & Session Management
Caché/ GT.M Server
Ajax Event Cycle (EWD)
![Page 22: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/22.jpg)
Ajax and the role of Javascript
• Container page doesn’t get replaced– Just changing bits of its DOM
• Javascript environment and context now remains in place across events and DOM changes
• Javascript now becomes a key part of the application
![Page 23: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/23.jpg)
Javascript Objects
• Javascript is an object oriented language
• Classless, dynamic objects– Add properties and methods arbitrarily and on
the fly– It’s how Caché Objects should have been
implemented!
• With Ajax, Javascript objects can persist throughout the user’s session
![Page 24: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/24.jpg)
Javascript Objects var MGW = {} ;
MGW.page = { currentPage: "compiler", section: new Array(), selectTab: function(obj) { var pageName = EWD.utils.getPiece(curr.id,"Tab",1) ; if (pageName != MGW.page.currentPage) { obj.className = "highlightedTab" ; MGW.page.newProperty = “some new value” ; } }
![Page 25: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/25.jpg)
Javascript Objects
• Also allow you to namespace methods and properties– eg, avoid function name clashes
• Key proponent and guru:– Douglas Crockford (Yahoo)– His training videos should be mandatory
viewing for anyone involved in Ajax work– http://developer.yahoo.com/yui/theater/
![Page 26: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/26.jpg)
Javascript to the fore!
• Session persistence in Javascript
• Application logic in Javascript:– Form field validation– Data manipulation: in and out of Javascript
objects
![Page 27: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/27.jpg)
Err….what about the back-end?
• In a “traditional” web application, the back-end did all the work– Application data storage– Session data persistence– Validation of data sent from browser– Retrieval of data from database and
transformation ready for presentation
![Page 28: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/28.jpg)
Err….what about the back-end?
• When using Ajax– Application data storage– Session data persistence– Validation of data sent from browser– Retrieval of data from database and
transformation ready for presentation
• Not very demanding role!!
![Page 29: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/29.jpg)
Consequences:
• In a Caché-based Ajax application, what need is there for:– Caché ObjectScript?– Caché Objects?
• Except persistent versions of the Javascript ones
• Indeed, does Caché bring any benefits as the back-end database of an Ajax application?– Just need to store and retrieve data
![Page 30: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/30.jpg)
The theory of “good enough”
• The web is founded on technology that is “good enough”– The Internet and the TCP/IP protocol– HTTP, HTML, Javascript
• Other “good enough” supporting technologies have also come to the fore:– MySQL– PHP
![Page 31: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/31.jpg)
Is Caché “too good” for Ajax?
• For small to medium-sized applications, MySQL is the obvious choice– It’s free– It’s “just there” and working on any LAMP
server you buy or hire• Nothing to buy, install or configure
• For corporates, Oracle or SQL Server will remain the obvious choices
• People will “make do” with “good enough”
![Page 32: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/32.jpg)
So is there a role for Caché etc?
• Caché (and similar technologies such as GT.M) have always excelled as:– Very high performance database– Massively scalable database– Extremely robust database– Low maintenance database
• DBA-less!
– Ie Enterprise-grade database technology
![Page 33: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/33.jpg)
• In the Ajax world, the core features of Caché, GT.M etc will benefit the top-end user
• Ironically all the “new stuff” is somewhat redundant in the Ajax world!
• So the really important space that Caché, GT.M etc can occupy is the massive, top-end enterprise Ajax application– eg Quest Diagnostics
So is there a role for Caché etc?
![Page 34: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/34.jpg)
Start small, grow large
• But most applications start small– Solutions such as MySQL are the clear choice
• Successful applications grow large– MySQL can scale– But there comes a point when it just can’t
scale easily to the really high end– Law of diminishing returns
![Page 35: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/35.jpg)
Two strategies
• Persuade the small to medium application developers to adopt Caché, GT.M etc– “just in case” they need to scale in the future
• Provide an easy transition from other solutions when needed– Direct database substitution
• Via SQL mappings• But not necessarily getting full advantage of the technology
– Technology-independent application framework• eXtc Web Developer
![Page 36: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/36.jpg)
EWD: Universal Framework
• EWD is built around an abstracted definition of a web application
• Although originally developed for Caché, it is now completely technology-agnostic
• EWD’s abstract definition can be used to generate code in any technology– and make use of any database
![Page 37: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/37.jpg)
EWD: Technology matrix
Web technology/
language
Persistence database Application database
PHP Caché, GT.M, MySQL Caché, GT.M, MySQL
Java Server Pages Caché, GT.M, MySQL Caché, GT.M, MySQL
Caché Server Pages Caché Caché
WebLink Caché Caché
ASP.Net (C# etc) Caché, GT.M, MySQL Caché, GT.M, MySQL
![Page 38: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/38.jpg)
• EWD therefore provides a universal framework for defining any web application for any technology combination– Isn’t this a threat to Caché, GT.M etc?
• Start small with EWD and MySQL
• Migrate simply to EWD and Caché/GT.M when the time comes for their power
EWD: Universal Framework
![Page 39: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/39.jpg)
Conclusions
• Caché or GT.M-focused Ajax solutions are doomed to being ignored by the mainstream– “good enough” (PHP, Ruby, Dojo etc) will prevail
• EWD’s technology-independence actually benefits Caché, GT.M etc in the new Ajax world– Caché, GT.M etc can and should dominate the high-
ground– We need to facilitate easy migration from “good
enough” when it no longer is• That’s where EWD comes in
![Page 40: Rob Tweed :: Ajax and the Impact on Caché and Similar Technologies](https://reader035.vdocuments.us/reader035/viewer/2022062704/555a44b3d8b42ae1398b50a5/html5/thumbnails/40.jpg)
Ajax and the Impact on Caché and Similar Technologies
Rob Tweed
M/Gateway Developments Ltd