Skip to content

Factory Pattern - should some kind of factory #136

@avnis838

Description

@avnis838

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions