design pattern - factory method

10

Upload: habibur-rahman-rony

Post on 08-Jul-2015

448 views

Category:

Technology


2 download

DESCRIPTION

Advantage- Helps to improve communication between developers. Proven Solution Reduce Reworking Disadvantages- Complex to Learn First let’s think that we wanna produce Ice cream maker. Not only Ice cream maker, conceptually to make it easy think about a Car Factory from where we produce car tier, horn, wheel etc. Here we’re creating the objects. So creational Pattern works with objects creation. Now the horns and car tier are not the same objects. They’ve the different behaviors. Horns make sound but Car Tier moves and car cross the distance. So both of them are object but they’re separated by their behavior. Behavior pattern works with object’s behavior. Finally to get a car’s structure we need to join all of the objects. So Structural Pattern works with object’s structure. So to get a final product we have to cross 3 form that is – Creational, Behavior & Structural Pattern. Let’s suck the Factory Methods. This is our Ice Cream factory from where we will create Ice Cream maker Machine according to the color. Say, client need an Ice cream maker which make red color ice cream. Another client also want ice cream maker which will make blue color ice cream. So ice cream makers are common to them. But their expected colors are not same. How?? Ok let’s see to the next slide. Let’s look at the diagram. When one customer choose blue color, factory will create that object which is blue color and send it to the client. After getting it and client is able to make blue color Ice Cream. Similarly choose red color and get an object. Make red color ice cream. So there are 2 jobs – 1. Make machine, I mean create object. 2. Make ice cream with this machine, I mean have work to do with this object. Factory Method highlights the first portion, I mean creating the objects. Here all of the objects inherits the same behavior but they’re different. Think about the Ice Cream maker, we get a machine according to the color and it make colorful Ice Cream. So at the run time you need objects then candidate pattern is Factory Method.

TRANSCRIPT

Page 1: Design Pattern - Factory Method
Page 2: Design Pattern - Factory Method
Page 3: Design Pattern - Factory Method
Page 4: Design Pattern - Factory Method
Page 5: Design Pattern - Factory Method
Page 6: Design Pattern - Factory Method
Page 7: Design Pattern - Factory Method
Page 8: Design Pattern - Factory Method
Page 9: Design Pattern - Factory Method
Page 10: Design Pattern - Factory Method