what is different between abstract factory and factory method?
I think abstract factory contain factory method. abstract factory is more flexible than factory method.
how do you think of that?
Roughly,
"In the Abstract Factory pattern, you create an entirely new class to hold the Create() methods for the objects you want to create. In the Factory Method pattern, you put abstract methods in your own class to Create() objects, and then depend upon the derivatives to implement them.
Abstract Factories are a little more flexible, but a little more complex than Factory Methods. You can change Factories at runtime, but you can't change Factory Method implementations at runtime."
That last sentence is language-dependent. It's possible in C#, for instance, to swap out implementations of a method by calling a delegate instead.
hope that helps,
"In the Abstract Factory pattern, you create an entirely new class to hold the Create() methods for the objects you want to create. In the Factory Method pattern, you put abstract methods in your own class to Create() objects, and then depend upon the derivatives to implement them.
Abstract Factories are a little more flexible, but a little more complex than Factory Methods. You can change Factories at runtime, but you can't change Factory Method implementations at runtime."
That last sentence is language-dependent. It's possible in C#, for instance, to swap out implementations of a method by calling a delegate instead.
hope that helps,
It's also possible in C++, but it's not a basic feature of the language, but it's no problem to built-in a multi-pass delegate.
An abstract factory creates a factors which creates the objects.
For Example an abstract factory for you GUI can do the following:
factory screen = abstract_gui_factory.createFactory( "TitleScreen" );
screen.createButton();
screen.createStaticText();
/*etc.*/
An abstract factory creates a factors which creates the objects.
For Example an abstract factory for you GUI can do the following:
factory screen = abstract_gui_factory.createFactory( "TitleScreen" );
screen.createButton();
screen.createStaticText();
/*etc.*/
Roughly,
"In the Abstract Factory pattern, you create an entirely new class to hold the Create() methods for the objects you want to create. In the Factory Method pattern, you put abstract methods in your own class to Create() objects, and then depend upon the derivatives to implement them.
Abstract Factories are a little more flexible, but a little more complex than Factory Methods. You can change Factories at runtime, but you can't change Factory Method implementations at runtime."
That last sentence is language-dependent. It's possible in C#, for instance, to swap out implementations of a method by calling a delegate instead.
hope that helps,
"In the Abstract Factory pattern, you create an entirely new class to hold the Create() methods for the objects you want to create. In the Factory Method pattern, you put abstract methods in your own class to Create() objects, and then depend upon the derivatives to implement them.
Abstract Factories are a little more flexible, but a little more complex than Factory Methods. You can change Factories at runtime, but you can't change Factory Method implementations at runtime."
That last sentence is language-dependent. It's possible in C#, for instance, to swap out implementations of a method by calling a delegate instead.
hope that helps,
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement