Your SlideShare is downloading. ×
0
Factory Method Pattern Define an interface for creating an object, but let subclasses decide which class to instantiate.  ...
Why Use Patterns <ul><li>Someone has already solved your problem </li></ul><ul><li>Common terms facilitate communication <...
Design Strategies recommended by GoF <ul><li>Design to Interfaces  </li></ul><ul><li>Favour composition over inheritance <...
Themes of Creational Patterns <ul><li>Encapsulate Knowledge about which concrete classes the system uses </li></ul><ul><li...
Factory Method Pattern Define an interface for creating an object, but let subclasses decide which class to instantiate.  ...
Applicability <ul><li>a class can't anticipate the class of objects it must create.  </li></ul><ul><li>a class wants its s...
Factory Method Structure
Consequences <ul><li>Eliminates binding to a specific implementation at instance creation. </li></ul><ul><li>Can increase ...
Implementation <ul><li>With or without default implementation. </li></ul><ul><li>Parameterized factory methods. </li></ul>...
Examples
Example 2
Upcoming SlideShare
Loading in...5
×

Factory Method Pattern

917

Published on

Presentation given on Aug 2006 at Symbion Health and on Jun 2007 at Melbourne Patterns Group

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
917
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
27
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Factory Method Pattern"

  1. 1. Factory Method Pattern Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
  2. 2. Why Use Patterns <ul><li>Someone has already solved your problem </li></ul><ul><li>Common terms facilitate communication </li></ul><ul><li>The patterns emphasize the importance of context </li></ul>
  3. 3. 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>
  4. 4. 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>
  5. 5. Factory Method Pattern Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
  6. 6. Applicability <ul><li>a class can't anticipate the class of objects it must create. </li></ul><ul><li>a class wants its subclasses to specify the objects it creates. </li></ul><ul><li>hiding which helper subclass has been delegated responsibility for implementing a task. </li></ul>
  7. 7. Factory Method Structure
  8. 8. Consequences <ul><li>Eliminates binding to a specific implementation at instance creation. </li></ul><ul><li>Can increase sub-classing. </li></ul><ul><li>Provides hooks for subclasses </li></ul><ul><li>Connects parallel class hierarchies </li></ul>
  9. 9. Implementation <ul><li>With or without default implementation. </li></ul><ul><li>Parameterized factory methods. </li></ul><ul><li>Using templates to avoid sub-classing. </li></ul><ul><li>Naming conventions. </li></ul>
  10. 10. Examples
  11. 11. Example 2
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×