Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Design and Architecture
  4. one questions about Builder Pattern

one questions about Builder Pattern

Scheduled Pinned Locked Moved Design and Architecture
comregextutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ahmed R El Bohoty
    wrote on last edited by
    #1

    i have one questions about Builder Pattern ..why we need product class where director class construct the component of product and when i want to produce any product i will implement IBuilder interface and write the behavior of each component and pass the concrete Builder to director without need the product and i will produce also different representation , plz give me the benefit of product class and real world example if u can ?

    Discover Other .... http://www.islamHouse.com

    C 1 Reply Last reply
    0
    • A Ahmed R El Bohoty

      i have one questions about Builder Pattern ..why we need product class where director class construct the component of product and when i want to produce any product i will implement IBuilder interface and write the behavior of each component and pass the concrete Builder to director without need the product and i will produce also different representation , plz give me the benefit of product class and real world example if u can ?

      Discover Other .... http://www.islamHouse.com

      C Offline
      C Offline
      CodingYoshi
      wrote on last edited by
      #2

      Builder pattern consists of 4 parts: 1. Builder-This is an abstract class 2. ConcreteBuilder 3. Director-This is the site where the construction occurs by calling the ConcreteBuilder 4. Product-This is the thing being built public class Demo { public static void main(String args[]) { Builder b = new ConcreteBuilder1(); Director d = new Director(); d.construct(b); // We tell director to construct a product using b as the builder and director // will call the appropriate methods on b. We do not need to know how the director // will do this, we assume the director knows this. Product aProduct = b.GetProduct(); // Now we ask b to give us the built product b = new ConcreteBuilder2(); d = new Director(); d.construct(b); Product anotherProduct = b.GetProduct()); } } Therefore, you need the product class because after all you are after the built product at the end. It is like going to a construction site and taking a builder with you. You ask the person in charge at the construction site (Director) to construct a house for you using the builder you introduced to the person in charge. The person in charge should know the sequence and what parts are needed to build a house but does not know how to build it. He simply asks the builder to build the parts. The builder now has a complete house. To see the completed house, you ask the builder for the house. I personally think we should ask the Director for the finished product as well and the director should ask the appropriate builder, but for some reason that is not the case.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups