Skip to content

Factory pattern #2

Description

@alexrochas

I saw three things. First you should only have an interface AnimalCreator if you gonna have more than one factory, in other case this is unnecessary complexity.

As common usage. Because factory and "creational patterns" in general are the ones who has coupling. You should study the benefits of have static methods and very specific methods. Like:

public static Cat createCat(){ //code here }
public static Cat createDuck(){ //code here }

With this approach you not have to deal with invalid creational arguments (and of course, not returning any null). If you really need some "customization" you could take a look at "builder pattern" (the one you implement, not a lazy lombok way kkk).

Again, take a look, see what you can use of what I've said and give me some feedback. Good study! \o.

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