Comparison Script Components with Script Classes



Hello everybody,

the last days I started to make myself familiarised with VBScript. Now I would like to have some advice from more experienced programmers. I do not really figure out, how the concepts of Script Components and Script Classes differ and for what use cases they are intended.

I) Both are quite similar:

(1) They give the opportunity to define public methods and properties to encapsulate the modules.

(2) Each can produce an object by calling:

Class: "new objectClass = New classname"
Component: "new objectComponent = GetObject(ComponentName)

And one can use the objects functions over the same syntax:
object.function


II) But there are some differences:

(1) With Components all code around the defined functions and classes is executed on the creation of a component-object. (Dirty for class definitions - what is the sense of this?)

(2) With classes one can define constructors and destructors like in C++ (sub class_initialize and sub class_terminate). That doesn't seem to work with components.

(3) It doesn't seem to work to define classes in components and make the definition usable to the calling script.

(..) perhaps there are some more I didn't figure out yet

III) Ways to use them

(1) Classes seem to be one way to write reusable libraries. I could define my classes each in a separate .vbs-file. Then including the necessary class-definitions to my .wsf-s by a xml tag like:
<script language="VBScript" src="filename.vbs">

(2) An other way would be to create a component for each kind of object I need. Then creating the objects with
Set objectComponent = GetObject (...)

IV) Best Practice

What would you advice to me. How do you build your strictly object-oriented libraries in VBScript? How do you build mixed procedural / object-oriented libraries.

I would be very happy if someone could provide me with some information about best practices on this field.

Thank you very much in advance,

Melanie Desaive


.



Relevant Pages

  • Re: best method to add users
    ... I am after some advice as to the best way to add users to AD, including email addresses, group memberships and setting a password. ... Or is the best way a vbscript? ... You can put the users in a spreadsheet and run a script ...
    (microsoft.public.windows.server.general)
  • Re: Ping Steve Yandl or other VBScript gurus
    ... post on the vbscript newsgroup and that got me going in the right direction. ... 'Run macro named createResumeFromFile, which has no arguments, and catch its ... 'Exit the script with the value of the return code from the macro/function. ... how to do what I want to do entirely in VBA or VBScript; ...
    (microsoft.public.word.vba.general)
  • Re: LDAP query information
    ... execution of the vbscript? ... The error message indicates the line number in the script, ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: Thank you Richard, Paul and urkec
    ... only built-in way to communicate with the person running the script is ... It is documented in the VBScript help file Script56.chm. ... You can use the ADO and ADOX objects to analyze and manipulate an existing ... dir cmd of each folder to a text file and have my script use that file ...
    (microsoft.public.scripting.vbscript)
  • Re: Ping Steve Yandl or other VBScript gurus
    ... Steve Yandl suggested using VBScript when I asked ... I'm trying to add one small wrinkle to the script and can't figure ... The macro that I am launching from the VBScript is ... be that 'dim bWaitOnReturn' didn't define the variable as Boolean but ...
    (microsoft.public.word.vba.general)