KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Note: Introduction to Shared Singleton Class: Dynamic Global Variables
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: April 28, 2025
This technical article is restricted to partners Only. Login with your Partner account to have full access to this article!!!
Log In


The 4D programming language is constantly evolving to provide a better coding experience for developers. Shared Classes and Singleton Classes were introduced in 4D 20 R5 to expand the scope of developer capabilities even greater. A shared class allows developers to instantiate a shared object with its own set of properties and functions; when combined with a singleton class, developers can ensure the shared object has a unique instance throughout every process. This technical note will discuss the fundamentals of the Shared Singleton Class and how to use it to effectively implement a store of dynamic global variables. These are values that can be accessed and modified safely across all processes.

This technical note will go over the basics of shared objects, shared classes, singleton classes, and finally shared singleton classes. Then, it will discuss how to implement a shared singleton class to maintain dynamic global variables-values that are readable across all processes and that can be modified between processes. The advantages of this implementation, especially over older approaches such as interprocess variables, will also be discussed. Additionally, this technical note includes a demo application that shows examples of the implementation in a few different scenarios.