Abstract Factory Pattern

563 views

Published on

Presentation given at Melbourne Patterns Group (Sept 2005)

http://htxt.it/ovLs

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
563
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Abstract Factory Pattern

  1. 1. Abstract Factory Pattern Provide an interface for creating families of related or dependent objects without specifying their concrete classes
  2. 2. Design Strategies recommended by GoF <ul><li>Design to Interfaces </li></ul><ul><li>Favour composition over inheritance </li></ul><ul><li>Find what varies and encapsulate it </li></ul>
  3. 3. Themes of Creational Patterns <ul><li>Encapsulate Knowledge about which concrete classes the system uses </li></ul><ul><li>Hide how these classes are created and put together </li></ul>
  4. 4. Applicability <ul><li>A system independent of how products are created </li></ul><ul><li>Independent families of products can be used </li></ul><ul><li>Within a family, sibling products should be use together </li></ul><ul><li>Reveal Interfaces of class library and hide implementation </li></ul>
  5. 5. Implementation <ul><li>Factory Method </li></ul><ul><li>Prototype </li></ul><ul><li>Builder </li></ul>
  6. 6. Abstract Factory using Factory Method
  7. 7. Consequences of Classic Abstract Factory <ul><li>It isolates concrete classes </li></ul><ul><li>Exchanging product families harder </li></ul><ul><li>Consistency among products harder to enforce </li></ul><ul><li>Supporting new kinds of products is difficult </li></ul>
  8. 8. Pluggable Factory John Vlissides C++ Report, February 1999
  9. 9. Consequences of Pluggable Factory <ul><li>Class structure is simpler </li></ul><ul><li>The factory interface tends to be more complex </li></ul><ul><li>Changing individual product types is easy. </li></ul><ul><li>Exchanging product families harder </li></ul><ul><li>Consistency among products harder to enforce </li></ul>
  10. 10. Implementation - 2 nd Dimension <ul><li>Dedicated Creators </li></ul><ul><li>Parameterized Creators </li></ul>
  11. 11. Extensible Factories Timothy R. Culp C++ Report, October 1999
  12. 12. Consequences of Extensible Factories <ul><li>Supporting new kinds of products is easier </li></ul><ul><li>Products are returned with same Interface </li></ul><ul><li>Less type safety </li></ul><ul><li>Exchanging product families harder </li></ul><ul><li>Consistency among products harder to enforce </li></ul>

×