Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Builder Design pattern

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic