- Web Services and the Internet Economy
- An Actual Possibility for a Web-Unique Service
- What Makes Us Unique
What Makes Us Unique
Before I begin to discuss how the outside world will interact with this basic system, let's look at the considerations, the pitfalls, and the ways in which we can seek to distinguish our offering. If there is one thing that the carnage of the dot-com frenzy should teach developers, it is that writing code is not the extent to which you can make a contribution to keeping the company alive.
The basic structure that can be reviewed in the source code will seem familiar to anyone who has created ASPs to deal with a database in a Microsoft environment. For those who are accustomed to Linux, just replace the calls to ADO with calls to your favorite MySQL API.
Our data engine ASP consists of three important structural areas: the management thread, which calls the other functions to perform the required tasks; the database interactivity functions, which define the specific calls to update and retrieve data; and the functions that construct the interaction with the user interface.
The underlying philosophy is that isolation of functionality is not just good for compiled languages. Instead of believing that only an ActiveX control qualifies as an object in object-oriented development, we can break down any programming task into elemental bits of functionality. In addition, using global variables and session-level cookies is far more widespread than is justified. By applying an overall design approach[md]and this is just one of many that are outlined in many computer books of "design patterns"[md]solutions will generally present themselves.
In this instance, the ASP is not acting in the more traditional capacity of constructing HTML that will be displayed to the user. To distinguish this product, one of our requirements is minimal user distraction. Without this requirement, periodic redirection of the browser would be acceptable. Instead, we do not want to change the interface unless there is new information to display.
The main thread section is the functionality that is always executed. It is the portion that reacts to query string variables and directs others portions of the page to execute. In this instance, the VBScript analogy to the C-style switch() function will be employed:
Dim strResponse Select Case Request("mode") Case "add" strResponse = AddNewGame Request("location"), Request("team"), Request("sport") Case "update" strResponse = UpdateGameInformation Request("game_id"), ... update information Case "list" strResponse = GetAllActiveEvents Case "info" strResponse = GetUpdates Request("game_id") End Select Reaponse.write strResponse Response.end
This is the main loop, which can be constructed in this way because different requests will utilize different portions of the page. For example, a provider updating game data will not want a list of all active games. Another thing to keep in mind is that none of the functions listed in this section will itself make a database call.
Each of these functions construct the script calls that interact from the hidden frame with the visible frame. This will be further explained when we discuss the user portion in the next article, but essentially the format is as follows:
Response.write "<scr" & "ipt language='javascript'>" Response.write "var arrayGames = new Array(" & GetGameRecords("active=true") & ");" Response.write "parent.setNewData(arrayGames);" Response.write "<scr" & ipt>"
First, the word script is broken in two because VBScript has an irritating habit of interpreting a full <script> tag, causing text parsing errors. It doesn't always happen, but I have been burned often enough to always code this way. Second, GetGameRecords is an actual database function. Finally, the functionality of data transfer is embedded in the parent frame of the user page.
As a last, brief conclusion to this server-side component, I will review the format of one of the database functions:
Function GetGameRecords(whereClause) [open recordset with whereClause] dim strResponse do while not recordset.EOF strResponse = strReponse & Record("game_id") & "|" & _ Record("team_one") & "|"& {ic:ccc] Record("team_two") & "|"& _ Record("score_one") & "|"& _ Record("score_two") & Record("description") & "," loop GetGameRecords = strResponse & "EOA" End function
There's not a whole lot to discuss here. The strategy is to take database records from a strictly database format and reconstitute them with only the necessary information to be displayed to the user. Instead of building the <TABLE> on the server, the client is allowed a degree of intelligence based on a data array.
Depending on your experience level, there might be much or very little in this approach and the source that is news to you. In the next article in this series, you will see how this is leveraged to produce a value-added client interface.