🧮 MATLAB THAUMATURGY DIFFICULTY: Adept Creational

The Singleton of Global Nexus

Ensure only one Global Nexus exists across the MATLAB workspace.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Conjuration // Nexus
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MATLAB PATTERN //
classdef GlobalNexus < handle
    properties (Access = private)
        NexusEnergy
    end

    methods (Access = private)
        function obj = GlobalNexus()
            obj.NexusEnergy = inf;
        end
    end

    methods (Static)
        function singleObj = getInstance()
            persistent localObj
            if isempty(localObj) || ~isvalid(localObj)
                localObj = GlobalNexus();
            end
            singleObj = localObj;
        end
    end
end

Singleton

The Global Nexus is a singular construct; attempting to instantiate two will tear the fabric of the workspace…

Runic Tags: #singleton #nexus #global