Tag Archives: ajax

Data representation

Data can be represented in text format for human and binary format for computer. Here my focus will be on text representation.

For application, we commonly use XML because:

  1. Its self-documenting format describes structure and field names as well as specific values. And it is easily digested by both human and machine.
  2. It is platform-independent, thus relatively immune to changes in technology and facilitate in data exchange across heterogeneous systems.
  3. It supports Unicode.
  4. It can represent common computer science data structures: records, lists and trees.
  5. It allows validation using schema languages such as DTD and XSD. XSDs are far more powerful than DTDs in describing XML languages. They use a rich datatyping system, allow for more detailed constraints on an XML document’s logical structure, and must be processed in a more robust validation framework.

With all the above advantages, it quickly becomes the standard of data exchange especially in web service world. However, XML also carries its disadvantages like it is verbose and the hierarchical model for representation is limited in comparison to an object oriented graph.

Other options:

  1. XML vs JSON - JSON is now more attractive than XML for kinds of data interchange that powers Web-based mashups and Web gadgets widgets. Why? Look at the articles below:
    • Fixing AJAX: XMLHttpRequest considered HarmfulYou don’t see much AJAX examples that access third party web services like Amazon, Yahoo and Google. That is because all the newest web browsers impose a significant security restriction on the use of XMLHttpRequest. That restriction is that you aren’t allowed to make XMLHttpRequest to any server except the server where your web page came from. If you attempt to do so, XMLHttpRequest will either fail or pop up warnings, depending on the browser you are using… Solution: Application Proxy, Apache Proxy or Use Script Tag Hack (On-demand Javascript).
    • JSON vs XML: Browser Security ModelThis article comments the solutions proposed above. It indicated that Script Tag approach is better than proxy.
    • JSON and Yahoo!’s Javascript API – This article will give you example of how to use Script Tag to communicate with Yahoo Web service API and bypass the restriction of XMLHttpRequest. The way to bypass XHR restriction is not using XHR at all. The cross-site requests are made by adding script tags to a document’s HEAD with DOM methods (i.e. [code]]czoxNDpcIi5hcHBlbmRDaGlsZCgpXCI7e1smKiZdfQ==[[/code])
    • Is JSON better than XML (a good objective review)
    • In conclusion, JSON enables you to use Script Tag approach to bypass XHR security restriction b/c JSON itself is part of Javasript. That makes JSON popular.
  2. YAML as an alternative of data serialization
  3. Java Serialization will take object to binary representation (versioning headache). XStream is a simple library to serialize objects to XML and back again.

For machine, data is represented in binary format:

  1. The art of assembly language (a free book that you can read online)
Leave a comment Continue Reading →

Why Flex for RIA, no AJAX?

Here is the list of reasons why I chose Flex for the RIA development.

  1. Write Once Deploy Everywhere – Flex generates SWF that runs on top of Flash Player VM and behaves consistently across different browsers, even mobile phones later. With this, all the browser compatibility issues are basically offloaded by Adobe.
  2. Solid programming model with rich widgets and libraries.
  3. AMF makes Flex object to Java POJO communication possible. No need to use verbose XML – Check out BlazeDS.
  4. Flex IDE is a plugin in Eclipse that gives stepwise debugging, UI design console, code completion and more. Working with Actionscript is like Java.
  5. Flex SDK is open source and free.
  6. Great support on video streaming
  7. Integrate with HTML, Javascript and CSS, so it is not invasive adoption.
  8. Support offline application via AIR – Adobe has been working on the Adobe Integrated Runtime (AIR) that allows for using existing web application development skills to build and deploy desktop applications. AIR is still in early development, but promises to allow developers to use their newly learned Flex skills to build desktop applications. No need to learn Swing, Applet…etc.
  9. Provide several RPC methods like HTTPService, WebService, AMF and JSON. AMF is 10x faster than SOAP. James Ward developed his Census Flex application to provide performance benchmarks for the different RPC methods in the mainstream RIA technologies. (Download)
  10. You can keep the state in the Flex app and have your server completely stateless.
  11. More to come! :)

 

Leave a comment Continue Reading →