Software Design Pattern - abstract factory pattern

The abstract factory pattern is a software creational design pattern that provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes.In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products.This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.

An example of this would be an abstract factory class DocumentCreator that provides interfaces to create a number of products (e.g. createLetter() and createResume()). 

The system would have any number of derived concrete versions of the DocumentCreator class like FancyDocumentCreator or ModernDocumentCreator, each with a different implementation ofcreateLetter() and createResume() that would create a corresponding object like FancyLetter or ModernResume. Each of these products is derived from a simple abstract class likeLetter or Resume of which the client is aware. The client code would get an appropriate instance of the DocumentCreator and call its factory methods. Each of the resulting objects would be created from the same DocumentCreator implementation and would share a common theme (they would all be fancy or modern objects). The client would need to know how to handle only the abstract Letter or Resume class, not the specific version that it got from the concrete factory.
A factory is the location of a concrete class in the code at which objects are constructed. The intent in employing the pattern is to insulate the creation of objects from their usage and to create families of related objects without having to depend on their concrete classes.[2] This allows for new derived types to be introduced with no change to the code that uses the base class.
Use of this pattern makes it possible to interchange concrete implementations without changing the code that uses them, even at run-time. However, employment of this pattern, as with similar design patterns, may result in unnecessary complexity and extra work in the initial writing of code. Additionally, higher levels of separation and abstraction can result in systems which are more difficult to debug and maintain. Therefore, as in all software designs, the trade-offs must be carefully evaluated.

Class diagram

Abstract factory.svg

The method createButton on the GuiFactory interface returns objects of type Button. What implementation of Button is returned depends on which implementation of GuiFactory is handling the method call.
Note that, for conciseness, this class diagram only shows the class relations for creating one type of object.

Comments

  1. Hi, Neat post. There's a problem with your site in web explorer, might check this? IE nonetheless is the marketplace leader and a good component of other folks will pass over your excellent writing because of this problem.

    Feel free to visit my website: clinica de ojos
    my webpage - where is aruba

    ReplyDelete
  2. Yоu want tо make yourself out there who feel as іf it occurred on the goals,
    but in Јanuary. Сhat should bе сoѕt effectіve way to the
    movies οr a toοth, consiԁer some of
    them think free dating is ѵerу intimidating.

    Malе Goаt & Female Rooster The malе Ox is able to get οn with Lichtenѕtein, who's reportedly been free dating since their early 30s and 40s are well known paid sites.

    My page ... http://www.dehengelsportsite.nl/

    ReplyDelete
  3. Kids will enjoy playing a game of putt-putt, or riding go carts in the Putt-Putt race zone.

    There are judges, judging on originality, easy to understand what
    is going funny and timing for each commercial bank.
    This is done with several teams of children can see and hunt for something, we
    tell them.

    Here is my weblog; 10th Birthday party ideas

    ReplyDelete
  4. Fun and nutritious Paleo Toddler Dessert Recipe. Pizza crust, bread, pancakes, and any food that contain sugar should be taken out and erased from the list of foods one
    can eat. - Vegetables are low in sodium less water retention.



    Look into my web page the paleo diet and cholesterol

    ReplyDelete
  5. I did not see anyone ωho uѕes Utheгνerѕe himself,
    his positіon aѕ any othеr" friends" bу Robert Luketіc, and thе boԁy!
    If уou ωаnt to finԁ someone who will be forсed іnto а" Save" button and уou feel overpowered оr uncomfоrtable, if you don't have a good impression, in fact have decent numbers in my lane. My nerves are on the restoration of the ladies who are looking for a committed relationship are still some good advantages of free dating violence.

    Also visit my blog; 1datingintheusa.com
    my website: Hasslefreedatingtv.com

    ReplyDelete
  6. This plan of yours is a plan of action, and that means you take action every single day.
    You need to utilise every tool and potential outlet you possibly can.
    , to all your fans.

    My blog Internet Marketing Plan

    ReplyDelete
  7. The best wedding planning i - Pad app is the one that is easy
    to use and has all of the organizational tools needed to plan an awesome wedding.
    (Here's the key difference. If you don't have time, think about hiring someone for
    Best wedding website.

    Look into my web site: wedding website about me
    My page :: wedding website announcements

    ReplyDelete
  8. Celebrities started getting yourself into the phenomenon on this
    viral video:. This show is much more edgy and busy, without crossing over within the radical crudeness of South Park.
    Best of You Tube Viral Video compilation.

    Also visit my web site: http://bellamcfarland.com

    ReplyDelete
  9. On Sunday nights Erin Jaimes hosts a blues jam where anyone from Alan Haynes to Gary
    Clark, Jr. *Rounds table format. The decline of the
    East side blues scene was disheartening, but, it also gave rise to the need for a fresh start, which came in the form of the next blues-only
    venue, Antone's, founded by the late Clifford Antone, during the summer of 1975.

    Feel free to surf to my site: Redtooth Pub Quiz Answers

    ReplyDelete
  10. Secondly, in moѵieѕ such аs milκ and want
    to quit thіs habit wіll help me in thе
    body to burn fat, and your needs and help you puгe green coffee beаn еxtrаct too.

    Simply put, eating dіsoгders are alѕo рacked
    wіth highеr levels of iodine in your six pack abs аnd thіghs.
    If you muѕt haνe gone through this pure green cоffee bean extract.
    Тecra R850 features а οne unique and ѕtrеtch occasiοnally.



    Here is my ωeb blog :: coffee diet

    ReplyDelete
  11. The other way to get more Facebook fans is by rewarding the loyal fans that
    you already have. Out of all them the best and most used one is
    to buy Facebook fans. Buy facebook fans or buy twitter followers is a
    way to increase the frequency of customer visits to your site and in other
    way, to bring more potential customers to your business.


    Also visit my homepage: get facebook fans

    ReplyDelete
  12. Those that are not familiar with the area will
    treasure this information above all else, and it will help them enjoy your wedding more thoroughly.
    Fortunately, our minister has neither, and he's asked very little of us as well. If you don't have time, think
    about hiring someone for Best wedding website.


    my homepage ... wedding website announcements

    ReplyDelete

Post a Comment