Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Builder Design pattern

 
aryan sanghvi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compact Computers is a small computer assembly company. Their online application allows customers to pick and choose accessories to build their own PCs. The accessories are:

i. Processor - 800Mhz, 1Ghz, 1.2Ghz

ii. HDD - 40 GB, 60 GB, 80 GB

iii. Memory - 128 MB, 256 MB, 512 MB

If a computer can have exactly 1 processor, 1 HDD and 1 memory stick, what pattern would be best used here?

A Factory Method

B Builder

C Prototype

D Abstract Factory

E Singleton

Can somebody please explain why it the answer is Builder ?
 
thalladi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sure you can understand why it needs to builder if see the example @

http://www.dofactory.com/Patterns/PatternBuilder.aspx

Satheesh
 
Kiran Ramamoorthy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We should use the builder pattern here for the following reasons.

a) To separate the construction process of the computer from its representation. This gives us the better control to keep the assembling process separately from the end object type.

b) Because we need to assemble several kinds of computer propreties objects like CPU, Monitor etc but result in a different object type (like ComputerModel based on assembled properties).

Example: http://www.c-sharpcorner.com/Code/2002/Feb/CreationalPatternBuilderAJ.asp

Regards,
Kiran.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic