Factory Design Pattern
bhaskarakster@gmail.com
What ?
• It Is a object creation software design pattern
bhaskarakster@gmail.com
When?
• If multiple subclasses exist for a super class and want to instantiate
one of the subclass based on input.
• If you want remove the instantiation of classes from client code, so
that code is not tightly coupled and class implementation can be
changed easily as client does not know the implementation of class.
bhaskarakster@gmail.com
How?
• Factory design pattern solves this requirement in the following way
• Create Factory method ( name the class as factory class) which takes the
input and creates instance of subclass and return the same.
• Create Abastract class through which Factory pattern can provide abstraction
between implementation and client classes.
bhaskarakster@gmail.com
Example
bhaskarakster@gmail.com
• Classed created as part of this example
bhaskarakster@gmail.com

Creational factory design_pattern

  • 1.
  • 2.
    What ? • ItIs a object creation software design pattern bhaskarakster@gmail.com
  • 3.
    When? • If multiplesubclasses exist for a super class and want to instantiate one of the subclass based on input. • If you want remove the instantiation of classes from client code, so that code is not tightly coupled and class implementation can be changed easily as client does not know the implementation of class. bhaskarakster@gmail.com
  • 4.
    How? • Factory designpattern solves this requirement in the following way • Create Factory method ( name the class as factory class) which takes the input and creates instance of subclass and return the same. • Create Abastract class through which Factory pattern can provide abstraction between implementation and client classes. bhaskarakster@gmail.com
  • 5.
  • 6.