Jump to content
  • Advertisement
Sign in to follow this  
derek7

what is different between abstract factory and factory method?

This topic is 4447 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I think abstract factory contain factory method. abstract factory is more flexible than factory method. how do you think of that?

Share this post


Link to post
Share on other sites
Advertisement
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,

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.*/

Share this post


Link to post
Share on other sites
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,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!