Builder Design Pattern in Visual Basic .NET

This pattern comes under Creational Pattern and this is used to create object. You can build complex object using simple objects. To understand the Creational Pattern we can think of a restaurant where you have kids meal menu and adult meal menu.

Now you can think that our Meal class is little bit complex because it has several items. So we build our meal by adding items to final meal. and also we have meals for adults and kids too

 

Meal Class

MealBuilder Interface
This is the interface that we are going to use our final Meal product , step by step

KidsMenu Concrete Class
This is concrete class which we used to make the Kids Meal.This class is the implementation of the MenuBuilder interface

AdultMenu Concrete Class
This is another concrete class which we use to build adult meal. This class is the implementation of the MenuBuilder interface. We have all methods and properties to build adult meal here

MenuDirector Class
Director can use CreateMenu method to build the Menu using MenuBuilder class

This is your Client to build the Menu

Leave a Reply

Your email address will not be published. Required fields are marked *