1. Home
  2. Computing & Technology
  3. Delphi Programming
RTL referenceGlossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link To
 
TASPObject - Continued
Discussing a complete web architecture using the TASPObject object. In this article, we are going to examine a skeletal structure for building a website that is extremely scalable.
 More of this Feature
• Page 1: Intro to TASPObject
• Page 2: ASP page counter
 Join the Discussion
"Post your questions, concerns, views and comments to this article..."
Discuss!
 Related Resources
• Internet programming
• Using components
• CGI/ISAPI articles

Article submitted by: Curtis W. Socha, http://www.absolute-research.com

   Introduction

Read before you start:
.Intro to ASP programming
.ASP Form Processing
.ASP Sessions
.ASP Meets COM
.ASP Applications
.Introducing the TASPObject class
Now that we know a little bit more about how the TASPObject works, let us now discuss a complete web architecture using this object. As I mentioned last lesson, it is completely possible to use this object to be your single entry point for all users. In this lesson, we are going to examine a skeletal structure for building a website that is extremely scalable.

This will be the only topic of this lesson and since there is a lot of code, I have decided to put the code in a downloadable file. The code is heavily commented and this tutorial requires quite a bit of hands on work and some serious thinking. Think you are up to it? If so, I promise you will walk away having learned at something new.

   So, what does this “architecture” look like?
It’s pretty simple really. Here is the basic structure of the website from a coding point of view:
a) Your COM object acts as a broker to the various web pages.
b) You will put each web page in a separate method and simply call that method depending upon what page is requested.
c) Each page is requested by passing the desired page along the querystring or along with the Form data via some variable.
d) All hyperlinks and forms point back to the main ASP that calls your COM object.
e) Your actual ASP file will not exceed the 13 lines of Delphi generated code, regardless of the size and complexity of your website! I bet you can’t wait to see how I do that…

   Why in the world would I want to do it this way?
For starters, your entire website is now in the Delphi environment. Second, your website is now a DLL. Should you want to send your website to a friend to host, all they have to do is register the DLL and set the Delphi generated ASP as their default page in their web server. Also, if you are using Win2K and you use the Application TASPObject example I showed you how to make in the last tutorial, you gain the benefit of never having to close down IIS in order to recompile. Just simply close the application. You can also track people as they traverse your website in real time. All these really cool things are possible using this technology.

   Well, I suppose it does sound interesting. Can I see this in action and can you show me the code?
Yep. The method I am going to use right now is for operating systems win98 and later. You could just as well use the application wrapped TASPObject that I showed you in the last lesson, but I want to make sure everyone can do this so we are simply going to use an in-proc-server for this architecture example. That example only works on Win2k and not everyone has Win2k yet.

So, go ahead and download the following code and compile, register the DLL, and put the .ASP file into a directory that you can browse to via your web browser.

Click here to download Lesson7.zip.

This code is rather advanced both syntactically and conceptually in relation to the other tutorials on my website. Here, we will be exploring several new objects and concepts:

a) The IRequestDictionary interface
b) The MethodAddress class function that exists in TObject (and problems with it!)
c) The TMethod record structure and how you can typecast methods to set their data/code pointers.
d) Invoking methods within your COM object via the forms collection or from the querystring.

All of these things are worth learning about and it will, at the very least, open your mind to a new way of designing architectures that are super-scalable because of abstract craftsmanship. There comes a point in every programmers life where they know most of the syntax, have coded some rather large cumbersome projects consisting of thousands and thousands of lines of code, and then they realize that there must be a better way to build large scale structures.

It is at that moment that they begin to explore abstract architecture concepts where the architecture isn't so damn rigid and you don't feel like your coding yourself into a corner. This exercise is not meant to tell you that my way is the best way to create a large-scale website. Nor is it meant to represent an ideal architecture. What it is supposed to do is show you how to use the IRequestDictionary object, use the MethodAddress class function, and most of all, to make you think outside of the box to see what is possible when you think of your construct in an abstract manner.

The rest of this tutorial is contained within the code comments. As I mentioned, it’s very hands on. It’s only 200 lines of code of which at least 75 of them are just comments.

   Summary
Whew! Seven tutorials is a lot to put out! I’m sure your just as exhausted as I am so I am not assigning anybody homework this week. By now, you should have enough information about ASP programming to build rather complicated websites and tools for your website. You should also walk away with a better working knowledge of how RTTI can play an important role in architecture design.

First page > An introduction to the TASPObject class > Page 1, 2

All graphics (if any) in this feature created by Zarko Gajic.

 More Delphi
· Learn another routine every day - RTL Quick Reference.
· Download free source code applications and components.
· Talk about Delphi Programming, real time.
· Link to the Delphi Programming site from your Web pages.
· Tutorials, articles, tech. tips by date: 2001|2000|1999|1998 or by TOPIC.
· NEXT ARTICLE: Deploying Delphi ADO database applications - DB/23.
Chapter twenty three of the free Delphi Database Course for beginners. It is time to make your Delphi ADO database application available for others to run. Once you have created a Delphi ADO based solution, the final step is to successfully deploy it to the user's computer.
 Stay informed with all new and interesting things about Delphi (for free).
Subscribe to the Newsletter
Name
Email

 Got some code to share? Got a question? Need some help?

Explore Delphi Programming

More from About.com

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2008 About.com, a part of The New York Times Company.

All rights reserved.