D
Daniel Billingsley
Let's say I'm writing a business app and I want there to be only one
instance of the Customer object for each particular customer (representing a
database record) being edited.
Would it be possible to extend the Singleton pattern to handle this?
Assuming that my Customer class follows the Singleton pattern (particularly
Skeet's 4th version) I'm thinking if I add
private static SomeCollectionType customers;
and then change the factory to something like
public static GetCustomer(Guid customerID)
{
// check collection and return existing instance if found
// create new instance and return if not
}
I think I have my mind around the static and singleton concepts, but need to
make sure.
instance of the Customer object for each particular customer (representing a
database record) being edited.
Would it be possible to extend the Singleton pattern to handle this?
Assuming that my Customer class follows the Singleton pattern (particularly
Skeet's 4th version) I'm thinking if I add
private static SomeCollectionType customers;
and then change the factory to something like
public static GetCustomer(Guid customerID)
{
// check collection and return existing instance if found
// create new instance and return if not
}
I think I have my mind around the static and singleton concepts, but need to
make sure.