Skip to content

Update abstract_factory more elaborate#370

Merged
faif merged 2 commits into
faif:masterfrom
yhay81:abstract_factory
Jan 25, 2021
Merged

Update abstract_factory more elaborate#370
faif merged 2 commits into
faif:masterfrom
yhay81:abstract_factory

Conversation

@yhay81
Copy link
Copy Markdown
Contributor

@yhay81 yhay81 commented Jan 24, 2021

After reading #366, I think it is not necessary to add more types of things but it can be more clear.

2 Points.

I think abstract factory can offer a concrete factory which can provide some different things from input/choice.
Then how about change show_pet() into something which can accept args like name?

abstract factory should have abstract_factory, concrete_factory and products.
And in former abstract_factory.py

abstract_factory: Class<PetShop>
concrete_factory: Class<Dog/Cat>
products: Pet Object?, string? or also output like print("woof")?

products is not clear.
So I returned Pet Object to make more clear what product is.

@yhay81
Copy link
Copy Markdown
Contributor Author

yhay81 commented Jan 24, 2021

And one question, why don't you use parent class?
It can force to have same methods, so we can do polymorphism in a safe way.

I know delegation is better than inheritance in many cases, but in this case I think the parent class Pet is good to be here.

@faif faif merged commit 2bdfe2a into faif:master Jan 25, 2021
@yhay81 yhay81 deleted the abstract_factory branch January 25, 2021 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants