Your SlideShare is downloading. ×
Factory Method Pattern
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Factory Method Pattern

774
views

Published on

Presentation given on Jun 2007 at Symbion Health and on Feb 2009 at Melbourne Patterns Group http://htxt.it/UXZe

Presentation given on Jun 2007 at Symbion Health and on Feb 2009 at Melbourne Patterns Group http://htxt.it/UXZe

Published in: Technology, Business

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

  • Be the first to like this

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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. Why Use Patterns
    • Someone has already solved your problem
    • Common terms facilitate communication
    • The patterns emphasize the importance of context
  • 3. Design Strategies recommended by GoF
    • Design to Interfaces
    • Favour composition over inheritance
    • Find what varies and encapsulate it
  • 4. Themes of Creational Patterns
    • Encapsulate Knowledge about which concrete classes the system uses
    • Hide how these classes are created and put together
  • 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. Applicability
    • a class can't anticipate the class of objects it must create.
    • a class wants its subclasses to specify the objects it creates.
    • hiding which helper subclass has been delegated responsibility for implementing a task.
  • 7. Factory Method Structure
  • 8. Consequences
    • Eliminates binding to a specific implementation at instance creation.
    • Can increase sub-classing.
    • Provides hooks for subclasses
    • Connects parallel class hierarchies
  • 9. Implementation
    • With or without default implementation.
    • Parameterized factory methods.
    • Using templates to avoid sub-classing.
    • Naming conventions.
  • 10. Examples
  • 11. Example 2