Factory Pattern is one of the most useful design pattern which we have to use in every day life. There are some variations in this pattern like abstract factory pattern and etc. According to the name, there is a client which order some factory to create objects rather than create products by himself.
I will demonstrate this using a Ice cream Factory. Assume we have several Ice cream factories which specializes on various topping types.
First we will create an Ice Cream Factory and Ice Cream.
Then we will create Chocolate Ice Cream and it's factory.
Then we will create Strawberry Ice Cream and it's company.
Then create an Ice Cream Seller which buy Ice Cream from various factories.
Below code will show, how the seller get various topping types, depending on the factory that seller buy Ice Cream.
No comments:
Post a Comment