Skip to main content
Edited question description.
Source Link
Number945
  • 5k
  • 10
  • 55
  • 90

I have read a lot of posts about different between Abstract Factory and Factory method, but there are a problem I can't understand.

One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation

Maybe I know why Abstract Factory pattern use composition and delegates to create object, but I can't understand why Factory Method pattern uses inheritance to create concrete class objects.


This question is not about what abstract factory is or what factory method is and hence does not have answer here

It is about why factory method seems to use inheritance when a client can call factory method directly too. Please unmark it as duplicate.

I have read a lot of posts about different between Abstract Factory and Factory method, but there are a problem I can't understand.

One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation

Maybe I know why Abstract Factory pattern use composition and delegates to create object, but I can't understand why Factory Method pattern uses inheritance to create concrete class objects.

I have read a lot of posts about different between Abstract Factory and Factory method, but there are a problem I can't understand.

One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation

Maybe I know why Abstract Factory pattern use composition and delegates to create object, but I can't understand why Factory Method pattern uses inheritance to create concrete class objects.


This question is not about what abstract factory is or what factory method is and hence does not have answer here

It is about why factory method seems to use inheritance when a client can call factory method directly too. Please unmark it as duplicate.

Edited title
Link
Number945
  • 5k
  • 10
  • 55
  • 90

Abstract Factory vs Factory method: Composition vs InplementInheritance?

Post Closed as "Duplicate" by Nathan Hughes, Bart, Undo, Achrome, László Papp

I have read a lot of posts about different between Abstract Factory and Factory method, but there are a problem iI can't understand.

"One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation"

One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation

Maybe iI know why Abstract Factory pattern use composition and delegates to create object, but iI can't understand why Factory Method pattern uses inheritance to create concrete class objects.

Can anyone can help me. Thank you! And sorry for my english!:)

I have read a lot of posts about different between Abstract Factory and Factory method, but there are a problem i can't understand.

"One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation"

Maybe i know why Abstract Factory pattern use composition and delegates to create object, but i can't understand why Factory Method pattern uses inheritance to create concrete class objects.

Can anyone can help me. Thank you! And sorry for my english!:)

I have read a lot of posts about different between Abstract Factory and Factory method, but there are a problem I can't understand.

One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation

Maybe I know why Abstract Factory pattern use composition and delegates to create object, but I can't understand why Factory Method pattern uses inheritance to create concrete class objects.

Source Link
Rey
  • 103
  • 2
  • 9
Loading