|
How to make static instances of a class |
Create a static method getInstances on the static instances' class that creates the instances, eventually caches them, puts them in an array and returns the array. The array must use the id of each object as the key of that object. See example 3.
You may also make a static method 'getInstance' that takes the id as its first parameter. This allows you to create only the required instance instead of all at once. |
|