Sunday 25 September 2022

 Design Pattern: Prototype & Singleton Design pattern 

a)Prototype Design Pattern:

This design pattern is next step of Abstract Factory, Factory or Builder design pattern. It will use a concrete class which is ready-made with all the parameter values  or most of them available. 

E.g. A shop X design comes with 6 chairs, 3 tables, 1 fridge, 200 juice bottles &

A shop Y design comes with 10 chairs, 3 tables, 2 fridge, 400 juice bottles, 200 glass soda bottles.

So user who needs X, he will directly chose that and one who needs Y, he will get all the facilities in ready-made format.

public  Shop selectShop(int budget){

 Shop shop;

if(budget > 1000000 && bugdet < 20 00 000){

  shop = new ShopX();

}

else if(budget > 20 00 000){

 shop = new ShopY();

}

else 

 shop = null;


return shop;

}

No comments:

Post a Comment