?
Solved

Differences between a VBScript Class and using includes

Posted on 2002-04-06
3
Medium Priority
?
729 Views
Last Modified: 2013-11-18
Is there any difference regarding performance, etc. in using a VBScript class file over an include file in an ASP page?
0
Comment
Question by:wsteph
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 6923379
I am not familiar with the use of a "VBscript class file", I am afraid you have to explain that one. (I found nothing relevant in MSDN when searching for it).

The SSI include is quite a basic function that uses very little resources. I once made a test where I had one file include hundreds of other files, and the execution time for this was not even noticable.

The concept of classes is quite different from including files, so the answer to your question must be that it depends very much on what you would be using it for.
0
 

Author Comment

by:wsteph
ID: 6923424
A VBScript class file is used in practically the same way a class in a dll would be. For instance say I have a file called methods.vbs and have the following code in that file:

<%
Class MyClassMethods
  Private Sub ConnectToDatabase()
    ...Code to connect to db
  End Sub

  Public Function GetRecords()
    ...Code to return db data to ASP page
  End Function
End Class
%>

I can call the methods in the script file much like I would call the methods in a dll from the ASP page like so:

<% @Language=VBScript %>
<!-- #include file="classes/class.cls" -->
<%
  Dim strHoldReturnData
  Dim objASPClass
  Set objASPClass = New MyClassMethods
  strHoldReturnData = objASPclass.GetRecords
  Set ObjASPClass = Nothing
%>

I was just wondering if there were any substantial differences between using this approach to encapsulate methods or just using a plain old include file that contains the methods. As you found out, Microsoft doesn't provide much information on this topic.
0
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 100 total points
ID: 6923933
Oh, you mean just a plain simple include file containing a VBScript class definition. :)

I have to disagree that the class file is used even remotely the same way as a dll. The class file is simply a plain text file that is added to the source before the ASP parser gets it's hands on it. To ASP it looks like a single file. Just because the include file has a special name or contains code for a class definition, there is nothing special with it; there is no added functionality over a plain include file.

Well, lets get to the point: As you use the same method for including functions and classes, there is no difference there. The only difference is encapsulating the code in a class. The overhead for this is not very much, though, it will add about a millisecond or two to the execution time of your code.

Usually objects is used to hold some kind of data. If your functions doesn't share any data, there is no reason to put them together in a class.

If you find it useful to construct a class, you should definitely do so, but not for the sole purpose of grouping some functions together.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question