mardi 4 octobre 2016

Naming a factory kind of class which return static objects

I have a dependency factory class, like

class DependencyFactory {
    @Autowired
    Dependency dependency1;

    @Autowired
    Dependency dependency2;

    public static Dependency getDependency(int arg1) {
        if (arg1 == 1) return dependency1;
        return dependency2;
    }
}

Now my confusion is on the name of the class DependencyFactory. I think this is not exactly a factory, but a decider class which return a predefined dependency based on the argument. So, is it ok to name is like DependencyFactory, or should it be something else?

Thank you. Please comment for any additional information.

Aucun commentaire:

Enregistrer un commentaire