Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modules vs. Classes vs. ActiveX DLL's 2

Status
Not open for further replies.

hinchdog

Programmer
Feb 14, 2001
380
US
If you're building a program, which is considered better to do, putting all your functions into Modules, Classes or ActiveX DLL's. They all seem like they do the same thing, but I figure one way is better and will make your application run the fastest. Anyone know this riddle of the sphynx??

^^
o:/_)
| | woof
 
There are big diffs, and also depends on what you're going to do, how program is used etc.
some examples:
if you are building a stand alone, self contained app, you might put all your func in a mod.

if you are building an n-tier app, you might want to only distribute the GUI to clients, and locate all your functions in a .dll on a server. One reason to do that is if you need to change some code in one of the func, you only need to change it one place(on the server) and not on multiple clients.

classes become objects, therefore, can be created(1 or more instances existing at the same time). Some things a class object can be used for are: Storing data(say, 1 cls obj per employee) & keeping these cls objs in collections(say, a collection of all the employees for the company, ie: a collection of 'Employee' class objects.)

just a few examples
JT Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
thanks for the info -- so if i have a self contained app i should use all modules then? i'm currenly using classes because i thought there might be a speed increase over modules and i like the funcitonality of COM objects. can i get away with this even though it might be overkill, or should i change them to modules? my only concern here is speed.

-thx

^^
0''_)
|_ |
||||
 
hinchdog -

As long as you set the instancing of the classes to Private, you won't have any real speed problems. This means that you won't be able to instantiate an object from these classes from other (outside) projects, but it sounds like you don't care about that ability.

If you're really interested in top-flight speed, you should watch where you're running loops. Inside those loops you should be using "with" clauses to speed up references to object properties and methods. For example:
[tt]
For i = 1 to 5
With txtMyField(i)
.top = 200 + (i * 20)
.left = 1200
.text = "bleh"
End With
Next i
[/tt]
This is fast. Faster yet would be if you unrolled the loop:
[tt]
With txtMyField(1)
.top = 220
.left = 1200
.text = "bleh"
End With
With txtMyField(2)
.top = 240
.left = 1200
.text = "bleh"
End With
With txtMyField(3)
.top = 260
.left = 1200
.text = "bleh"
End With
With txtMyField(4)
.top = 280
.left = 1200
.text = "bleh"
End With
With txtMyField(5)
.top = 300
.left = 1200
.text = "bleh"
End With
[/tt]

Note that the value for .top has been precalculated as well.

Chip H.
 
that for the tips. two more question...

what's up with the Call method to use subs. I noticed that you can use it or not. what's the difference. right now i'm not using it.

another, it it a good idea to elliminate any variable declarations that can be avoided? i ususal use alot of variables because it's clean looking, am i slowing down my app?

peace,
hinchdog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top