Fog Creek Software
Discussion Board

Object Caching in VB

I'm new to Visual Basic 6 and I'm trying to implement a pretty basic OO design pattern...

I want to create an object cache for a web application, but under the schema i'm familiar with, I'd like to have an ObjectController of some sort that would be accessed by the application and would return cached instances of data objects relevant for display (in the past, i've done this using Factory design patterns in Java)...  So all i have is a wrox book and the web, but I can't find anything on instantiating static objects, nor can i find any information about holding references to objects in ASP.  I assume this is possible, but I could use some help!

Anyone have any design suggestions or implementation resources i could refer to?  how would one implement this in VB6?

Friday, November 8, 2002

I haven't worked with ASP in a few years, but I believe there's a way to store objects on the session or application objects available in the ASP page (session/appliaction attributes in jsp). I believe VB has an associative array data structure (collection?) that you can use to store the cached instances. That's the basic idea, someone with better VB knowledge can fill in the exact class names.

BTW, is your app only going to run on one machine? You may be asking for trouble if you need to maintain cache coherency across multiple machines.

Friday, November 8, 2002

I write standalone applications but maybe this will help.

This is done all in VB6 SP5.

I have a need to maintain and add different file types. It is done in the following way with ActiveX DLLs.

Interface DLL
Specify the interface of the following
IFileFactory  (has one method Organize which accepts
                    one Parameter.
                    aFileTypeList as FileTypeList
FileTypeList (a strongly typed collection class of IFileType)

Application DLL
Contains the object FileTypes which is an instance of FileTypeList.

References InterfaceDLL

Has one object called FileTypeFactory which implements IFileTypeFactory. This is set to MultiUse.

Has File Types that are set to Public Not Creatable and implement IFileType in various ways.

Application EXE
References Interface DLL and Application DLL

Has a init section that goes like this

Sub FileTypeInit()
      Dim MyFactory as IFileTypeFactory
      Set MyFactory = CreateObject("FileTypeDLL.FileTypeFactory").
      MyFactory.Organize FileTypes
      Set MyFactory = Nothing
End Sub

Now I use CreateObject despite the speed hit because I only need to use it ONCE to grab the Factory. It allows me to have run-time loaded libraries where all you need to enter a string to load a library after it is installed. You can use References instead and go  Set MyFactory = New FileTypeFactory.

Rob Conley
Friday, November 8, 2002


I would consider checking out the list at - it covers these kinds of issues.


Matthew Wills
Sunday, November 10, 2002

*  Recent Topics

*  Fog Creek Home