• Post Reply Bookmark Topic Watch Topic
  • New Topic

Builder Pattern  RSS feed

 
Ankur Mehrotra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to Solve a particular Problem using Builder Pattern

1. Class A has 10 instance variables out of which 3 variables are compulsory for initialization rest can be also used if you want to crate an object
2. Instead of 8 different constructors having 3,4,5,6,7,8,910 arguments ,Provide a neat and clean solution to implement it using builder pattern.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur Mehrotra wrote:How to Solve a particular Problem using Builder Pattern

Look it up (Here might be a good place to start for practical advice).

Otherwise, I don't see a question we can answer Ankur. And this site is NotACodeMill (←click).

On the other hand, we're more than happy to help if you ShowSomeEffort.

Winston
 
Ankur Mehrotra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a solution to the problem is in Class A, has a single constructor having the three compulsory variables . the rest we create 7 setters for the variables so any object can be created first with compulsory three variables and then the other variables can be set through setter....but I think this is not a Builder Pattern...I have studied builder pattern, but I am unable to figure it out how to solve this particular problem through Builder Pattern
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur Mehrotra wrote:...I have studied builder pattern, but I am unable to figure it out how to solve this particular problem through Builder Pattern

Have a look at my post again (I've edited it with a link).

Otherwise, you need to explain to us what you understand by the Builder pattern, and why you can't translate it into Java (because that's all you're doing - translation).

Winston
 
Ankur Mehrotra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Guys ...will keep in mind before posting any questions. & Thanks for helping me.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur Mehrotra wrote:Sorry Guys ...will keep in mind before posting any questions. & Thanks for helping me.

No probs. Just remember, we're all volunteers here, so the more you can help us to answer your question, the more help you're likely to get.

And if it hasn't already been said: Welcome to the Ranch.

Winston
 
Ankur Mehrotra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will Remember...Thanks for your advise & Guidance
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!