Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you write client side applications?

Status
Not open for further replies.

scorpio66

Programmer
Jun 27, 2001
229
0
0
GB
This isn't a question about how to go about writing client side applications, more of a discussion on your methodologies and techniques. Any code shown is a simplification.

For example, I tend to have very small web pages (basically just placeholders) which is populated at run-time using Web Services.

At the backend all of my database queries return the datasets as XML which I pass transparently to the client.

Code:
SELECT COL1, COL2, COL3 FROM TABLE FOR XML AUTO

The client then converts the XML to native javascript objects - I know this may be redundant but I prefer dealing with methods and properties rather than constantly running up and down an XML document.

Code:
var xmlData = wsReturn.selectNodes('//TOPNODE')
for (var i=0; i<xmlData.length; i++) {
  var o = new obj();
  o.populateFromXML(xmlData[i]);
  col[o.id] = o;
}

A lot of my javascript objects are UI based and are in their own .js files for reusability. Because of the lack of namespaces in Javascripts all js files have at most 1 global variable - for example, in slider.js:

Code:
var slider_global = {
    global1: value
  , global2: value
  , global3: value
}

function fn() {
  if (slider_global.global1 == value) {
    // do something
  }
}

JSON is used extensively throughout the code (more out of laziness than anything else) and any code that I think may be browser specific is encapsulated into separate functions.

Anyone care to enlighten us with some of their own thoughts?

Chaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top