Benefits of singletons
- Last Updated: January 29, 2026
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
When an instance is created, you have a reference to the instance. You are responsible for the life cycle of the instance. In some cases, you may want to have a global instance that is available to all code running in the ABL Virtual Machine (AVM).
For example, you may want to have a single class instance that provides security for your application that all application code can access. You can implement this by defining a class that has a static constructor and static data members. One of the static data members is used to hold an instance of the class in the AVM. This data member must be public. This single class instance is called a singleton.
A static constructor behaves differently from a regular constructor. You cannot call a static constructor in your code. When an application starts, the static constructors for all singletons are called automatically. You must add code to these static constructors to create an instance of the class and assign it to the static data member. Any code that runs in the AVM has access to this static data member. You do not define parameters for a static constructor.
Note: Singleton classes are used extensively in applications that utilize a state-free operating mode in the application server, such as Progress OpenEdge Data Object Services that can be accessed via a REST protocol by web and mobile clients.
- Comparison with procedure-based programming main block in Develop Object-oriented ABL Applications