static void Main(string[] args)
        {
            Console.WriteLine("Fluent Builder design pattern example");
            Console.WriteLine("Builder is a creational design pattern, which allows constructing complex objects step by step.");
            Console.WriteLine();

            // the client code creates a builder object, passes it to the director and then initiates the construction process.
            // the end result is retrieved from the builder object.
            var director = new Director();
            var builder  = new ConcreteBuilder();

            director.Builder = builder;

            Console.WriteLine("Standard basic product:");
            director.BuildMinimalViableProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            Console.WriteLine("Standard full featured product:");
            director.BuildFullFeaturedProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            // remember, the builder pattern can be used without a director class.
            Console.WriteLine("Custom product:");
            builder
            .BuildPartA()
            .BuildPartC();
            Console.Write(builder.GetProduct().ListParts());
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // The client code creates a builder object, passes it to the
            // director and then initiates the construction process. The end
            // result is retrieved from the builder object.
            var director = new Director();
            var builder  = new ConcreteBuilder();

            director.Builder = builder;

            Console.WriteLine("Standard basic product:");
            director.BuildMinimalViableProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            Console.WriteLine("Standard full featured product:");
            director.BuildFullFeaturedProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            // Remember, the Builder pattern can be used without a Director
            // class.
            Console.WriteLine("Custom product:");
            builder.BuildPartA();
            builder.BuildPartC();
            Console.Write(builder.GetProduct().ListParts());
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var builder  = new ConcreteBuilder();
            var director = new Director();

            director.Builder = builder;

            director.BuildMinimalViableProduct();
            Console.WriteLine($"{builder.GetProduct().ListParts()}");

            director.BuildFullFeaturedProduct();
            Console.WriteLine($"{builder.GetProduct().ListParts()}");

            builder.BuildPartA();
            builder.BuildPartC();
            Console.WriteLine($"{builder.GetProduct().ListParts()}");
            ;
        }
        static void Main(string[] args)
        {
            // The client code creates a builder object, passes it to the
            // director and then initiates the construction process. The end
            // result is retrieved from the builder object.
            var director = new Director();
            var builder  = new ConcreteBuilder();

            director.Builder = builder;

            Console.WriteLine("Standard basic product (variation #1):");
            director.BuildMinimalViableProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            Console.WriteLine("Standard full featured product (variation #2):");
            director.BuildFullFeaturedProduct();
            Console.WriteLine(builder.GetProduct().ListParts());

            Console.Read();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var director = new Director();
            var builder  = new CarBuilder();

            director.Builder = builder;

            Console.WriteLine("Standard basic product:");
            director.BuildMinimalViableProduct();
            Console.WriteLine(builder.GetCar().GetParts());

            Console.WriteLine("Standard full featured product:");
            director.BuildFullFeaturedProduct();
            Console.WriteLine(builder.GetCar().GetParts());

            // Remember, the Builder pattern can be used without a Director
            // class.
            Console.WriteLine("Custom product:");
            builder.BuildChassis();
            builder.BuildEngine();
            Console.Write(builder.GetCar().GetParts());
        }