-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Open
Description
Current Factory Pattern has Application file with Tight coupling of new Subscriptions for the Different customers.
But if the creation of Subcription changes this also needs to be changed.
public class Application {
static public DataBase dataBase;
public static void main(String[] arg) {
dataBase = new DataBase();
SubscriptionFactory factory = new SubscriptionFactory(dataBase);
Customer customer1 = new Customer("1");
Customer customer2 = new Customer("2");
Customer customer3 = new Customer("3");
customer1.SubscribePlan(factory.getSubscription("gold"));
customer2.SubscribePlan(factory.getSubscription("silver"));
customer1.updateSubcribePlan(factory.getSubscription("royalGold"));
customer2.unSubscribePlan();
customer3.SubscribePlan(factory.getSubscription("platinum"));
}
}
this way Factory implementation is based on Dependecy injecting database.
Metadata
Metadata
Assignees
Labels
No labels