Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 166489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:06:24+00:00 2026-05-11T12:06:24+00:00

I have looked for a good example of a Builder pattern (in C#), but

  • 0

I have looked for a good example of a Builder pattern (in C#), but cannot find one either because I don’t understand the Builder pattern or I am trying to do something that was never intended. For example, if I have an abstract automobile and abstract builder methods to create car parts, I should be able to send all 30 of my choices to the Director, have it build the pieces I need, then build my automobile. Regardless of which car, truck, semi, etc. produced, I should be able to ‘drive’ it in exactly the same way.

First problem is most examples hard code property values in to the concrete parts, which I really think should come from a database. I thought the idea was to send my choices to the Director (from a data source) and have the builder create a customized product based on my data.

Second problem is I want the builder methods to actually create the parts then assign them to the product, not pass strings but real strongly typed product parts.

For example, I want to create a form on the fly by having a Builder manufacture form fields for me, including a label, an input section, validation, etc. This way I can read the object from my ORM, check out the object’s metadata, pass this to my Builder and add the newly created user control result to my web form.

However, every Builder example I find only has hard coded data instead of passing choices from the main code to the Builder and kicking out a customized product. Everything seems to be a big static case statement. For example, if I have three parameters with 10 choices each, I don’t want to build 30 concrete Builder methods, I want to create only enough to manufacture the properties my product requires, which may be only three.

I am tempted to have the Director exist in the main code only. There should be a way to automatically determine which concrete builder method to call similar to polymorphism and method overloads (although that is a very bad example) instead of using a case statement within the pattern. (Every time I need to add a new product type, I will need to modify the existing Director, which is bad).

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:06:25+00:00Added an answer on May 11, 2026 at 12:06 pm

    I am going refer to the C# example in the Wikipedia Article here.

    First problem is most examples hard code property values in to the concrete parts, which I really think should come from a database. I thought the idea was to send my choices to the Director (from a data source) and have the builder create a customized product based on my data.

    In this case you would have class implementing PizzaBuilder that knows how to retrieve data from a database. You can do it several ways.

    One would be make a HawaiianPizzaBuilder. When the class initializes it queries the database for a Hawaiian Pizza and retrieves the row. Then when the various Build(x) methods are called it would set the properties to the corresponding field of the retrieved database row.

    Another would be just makes a PizzaDatabaseBuilder and make sure that when you initialize the class you pass it the ID of the row you need for that type of pizza. For example instead of

    waiter.PizzaBuilder = new HawaiianPizzaBuilder(); 

    You use

    waiter.PizzaBuilder = new PizzaDatabaseBuilder('Hawaiian'); 

    Second problem is I want the builder methods to actually create the parts then assign them to the product, not pass strings but real strongly typed product parts.

    Should not be an issue. What you need is an other Factory/Builder type pattern to initialize the fields of the Pizza. For example

    instead of

     public override void BuildDough()   { pizza.Dough   = 'pan baked'; } 

    you would do something like

     public override void BuildDough()   { pizza.Dough   = new DoughBuilder('pan baked'); } 

    or

     public override void BuildDough()   { pizza.Dough   = new PanBakedDoughBuilder(); } 

    DoughBuilder can go to another table in your database to properly fill out a PizzaDough Class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked over the Repository pattern and I recognized some ideas that I
I have looked around on the Internet trying to answer this question. It seems
I have looked at the Suggested related questions but none of them are what
I have looked at the SQL Server 2008 feature comparison matrix and it lists
I have looked at NHibernate and EntitySpaces and they both seem to work differently.
I have looked on FaceBook Developer page and found that it's possible to create
I have looked all of the place for this and I can't seem to
I've used jdom in the past, and have looked briefly at XOM and DOM4j
Do you plan on using Factor ? Have you looked at it? Checked it
I have some accesses from 192.168.0.71 on my apache logs. I looked up this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.