When my application starts up it needs to get an instance of the correct DAL class (currently there are 4) based on what user is logged in. Certain users are pulling down from certain databases.
Is it still considered a "factory" pattern if instead of instantiating instances of those DAL classes, I simply return the correct static instance of it? I have no need to continually create these objects since all users can share them.
Psuedocode:
public class RepositoryFactory
{
public static IRepository repoA = new FranksLumberRepo();
public static IRepository repoB = new LowesHardwareRepo();
public static IRepository repoC = new HackmansHardwareRepo();
public static IRepository repoD = new TomsHardwareRepo();
public IRepository createRepo(User currentUser)
{
switch(User.Store)
{
case FrankLumber:
return repoA;
case LowesHardware:
return repoB;
case Hackmans:
return repoC;
case TomsHardware:
return repoD;
default:
throw exception;
}
}
}