Classes/objects in VBScript

Results 1 to 2 of 2

Thread: Classes/objects in VBScript

  1. #1
    Join Date
    Dec 1969

    Default Classes/objects in VBScript

    I come mainly from a procedural programming background (C, Perl, Basic). I&#039ve been writing ASP apps for my company&#039s intranet for a while now. Recently I read up on using classes in VBScript, and learned the concepts involved.<BR><BR>My question is, are a lot of developers rolling their own classes in straight ASP/VBS scripting? My systems are already highly organized and easy to maintain through extensive use of neat, efficient functions/server-side includes. I&#039m just having difficulty seeing how the OOP programming model benefits ASP scripting using VBScript.<BR><BR>In the articles and book examples I&#039ve read, they all show you the syntax, but not one of them gives a real world example of how classes are more helpful than smart, tight modularization of your code through the use of functions, subs, and SSI. Anyone care to share what they&#039re doing in this area?<BR><BR>Thanks,<BR>Jerry.<BR><BR>P.S. - I&#039m not referring to COM, or the built-in set of objects that we all use as ASP developers. I fully realize the OOP principles involved in using those. I&#039m only referring to scripting your own classes/objects.

  2. #2
    Richard A. Lowe Guest

    Default RE: Classes/objects in VBScript

    Jerry, I think you&#039re right that most of the time, well implemented functions and granular SSIs will suffice and script objects are probably more of a design headache than is needed.<BR><BR>I can&#039t say for VBScript classes, but I use JScript objects all the time. One of the best arguments for them is imlementing security: JScript objects support a &#039crude&#039 type of inheritance that allows security permissions objects to cascade permissions in a hierarchical fashion, making it much easier to implement group and individual security structures.<BR><BR>Other than that, I&#039ve modeled objects (sometimes successfully, other times not) and created JScript-based object interfaces to them that made assembling my application easier. Also, it makes it easier to maintain standards IMHO, because your interfaces are bundled into (supposedly) well-defined objects (when it&#039s appropriate).<BR><BR>A simple successful example is a Data Access object I created that I now use in ALL my small to medium applications:<BR><BR>function cData() {<BR> this.Connection = new Object;<BR> this.GetString = mGetString;<BR> this.GetRecordset = mGetRecordset;<BR> this.GetShapedRecordset = mGetShapedRecordset;<BR> this.GetConnection = mGetConnection;<BR> this.GetHTML = mGetHTML;<BR> this.Execute = mExecute;<BR>}<BR><BR>this.Connection is the ADO connection object I pass to the object as a property and the rest are methods I have implemented to make a very flexible way to access data.<BR><BR>I invoke this object at the beginning of the page (it&#039s in a SSI) and close it at the end, and rarely have to worry about it&#039s implementation. The same could be accomplished with functions, I simply find the object format to be easier to use.<BR><BR>HTH,<BR>Richard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts