Factory Pattern

350 views

Published on

1. Factory Method Pattern Shahriar Iqbal Chowdhury & Monjurul Habib Code Name: Remington http://www.facebook.com/groups/netter/
2. Why We need Factory? Caveman Example
3. The Solution
4. A specialist for the job
5. Factory Pattern Method Basics• Creational Pattern• Which object to create• It lets a class defer instantiation to subclasses.• Absolutely all constructors should be private or protected• Also known as Virtual Constructor.
6. When to consider?• When we have a class that implements an interface but not sure which object, which concrete instantiation / implementation need to return.• When we need to separate instantiation from the representation.• When we have lots of select and switch statements for deciding which concrete class to create and return.
7. Factory SaysDefine an interface for creating an object, but let subclasses decide which class to instantiate
8. Problem without Factory Method Pattern
9. Solution Applying Factory Method Pattern
10. Banking Account Management System
11. Object is created based onconfiguration parameters
12. Violation of OCP(Open ClosePrinciple of SOLID)
13. we will need to create a property that indicates type in each account class

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

  • Be the first to like this

No Downloads
Views
Total views
350
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • once upon a time caveman's were happy, their need was small, their hunting gear is big enough for their prey
  • Soon their more mouth to feed, with that amount of hunting they can do only one thing!! Cutting... OR hunting bigger prey. Is that easy???
  • Hummm, seems that idea didn't workout well.
  • Its time to call the hunter and enjoy the meal :)
  • The client is an object that requires an instance of another object for some purpose. Rather than creating the product instance directly, the client delegates this responsibility to the factory. Once invoked, the factory creates a new instance of the product, passing it back to the client. Put simply, the client uses the factory to create an instance of the product. 
  • Use Reflection
  • Factory Pattern

    1. 1. Factory Method Pattern Shahriar Iqbal Chowdhury & Monjurul Habib Code Name: Remington http://www.facebook.com/groups/netter/
    2. 2. Why We need Factory? Caveman Example
    3. 3. The Solution
    4. 4. A specialist for the job
    5. 5. Factory Pattern Method Basics• Creational Pattern• Which object to create• It lets a class defer instantiation to subclasses.• Absolutely all constructors should be private or protected• Also known as Virtual Constructor.
    6. 6. When to consider?• When we have a class that implements an interface but not sure which object, which concrete instantiation / implementation need to return.• When we need to separate instantiation from the representation.• When we have lots of select and switch statements for deciding which concrete class to create and return.
    7. 7. Factory SaysDefine an interface for creating an object, but let subclasses decide which class to instantiate
    8. 8. Problem without Factory Method Pattern
    9. 9. Solution Applying Factory Method Pattern
    10. 10. Banking Account Management System
    11. 11. Object is created based onconfiguration parameters
    12. 12. Violation of OCP(Open ClosePrinciple of SOLID)
    13. 13. we will need to create a property that indicates type in each account class

    ×