Comparison Script Components with Script Classes
- From: Melanie Desiave <melanie.desaive@xxxxxxxxxx>
- Date: Fri, 10 Mar 2006 12:20:52 +0100
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
.
- Follow-Ups:
- Re: Comparison Script Components with Script Classes
- From: mayayana
- Re: Comparison Script Components with Script Classes
- Prev by Date: LOGIN SCRIPT
- Next by Date: Importing certificate in IE using VBS
- Previous by thread: LOGIN SCRIPT
- Next by thread: Re: Comparison Script Components with Script Classes
- Index(es):
Relevant Pages
|