The Singleton of the Global Address Space
Ensuring only one instance of a global COM object corrupts the memory.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Abjuration // Isolation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// VB PATTERN //
' Module: ModSingleton.bas
Private m_Instance As Object
Public Function GetInstance() As Object
On Error Resume Next
If m_Instance Is Nothing Then
' A global anchor
Set m_Instance = CreateObject("Scripting.FileSystemObject")
End If
Set GetInstance = m_Instance
End Function
In the lawless lands of VB6, global modules are the easiest path to Singletons. This pattern restricts instantiation, ensuring that all threads gaze upon the exact same cursed file system object.
Runic Tags:
#singleton
#global
#com