?
Solved

Differences between a VBScript Class and using includes

Posted on 2002-04-06
3
Medium Priority
?
743 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
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

862 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