[ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ]


Objects make the world go 'round

When we build applications, business objects that contain the structure and business logic of our application are key in making things work properly. They abstract and isolate this logic into a central structure that is easy to maintain and administer. Because objects often describe a particular piece of information about an application, they also make great containers for data, depending on how the business objects are structured.

For example, on my Web site most business objects include member objects that hold the actual data. An inventory object for my Web Store application has an oData member that contains the actual item information - in this case, simply the fields of the inventory item record added to the Item object with SCATTER NAME loItem.oData MEMO. This works for local data pulled from Visual FoxPro tables, or for data pulled from a SQL backend like SQL Server or Oracle via ODBC or ADO/OleDb. Once loaded, to get access to the data, I can use the following code:

    loItem = CREATEOBJECT("cItem") 
    loItem.Load( 1241 ) && Customer PK 
    ? loItem.oData.Sku 
    ? loItem.oData.Descript

Methods on the object can then be used to perform operations on this business object. If I make a change to the item description and save the change, I'd use:

    loItem.oData.Descript = "West Wind Web Connection 3.20" 

Since this object is self-contained and has its own logic to deal with typical tasks of loading and saving, it's very easy to use, and can be passed around as a message inside the local application, or even in COM method calls across application boundaries.

Wouldn't it be nice if you could also pass an object like this around over the Web? The answer to doing this lies in persisting the object member data into XML, and then passing this XML over the wire. wwXML supports this functionality using the ObjectToXML method. On my Web store site most URLs can be accessed by adding a special flag to the HTML display URLs. For example, to display item data for a product on the Web site I can use the following URL:


Figure 3 - Item object rendered as HTML using standard templates with ASP syntax

This gives me an HTML page. The Web application renders the data using a cItem object instance referenced in template tags (like <%= oItem.oData.Descript %> for example) that are expanded on the HTML page. I can also get that same information in XML format by adding &display=XML to the end of the URL:


[ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ]