Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Builder vs Abstract Factory

 
Joe O'Toole
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I was hoping somebody might be able to help me with a question from javabeat:

Compact Computers is a small computer assembly company. Any customer currently has the following choices for a PC:



(i) 800 MHz processor, 40 GB HDD, 128 MB RAM

(ii) 1 GHz processor, 60 GB HDD, 256 MB RAM

(iii) 1.2 GHz processor, 80 GB HDD, 512 MB RAM



The use of what design pattern would ensure that only the legal combinations could be sold?



A Factory Method

B Builder

C Prototype

D Abstract Factory

E Singleton



Choice D is correct.



To me this is a perfect fit for the builder pattern. Interested to see what other folks think

Thanks
Joe
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is poor and illustrates only a superficial understanding of software design, design patterns in general, and the specific ones highlighted as possible answers.

The question implies and assumes that only one pattern could be used to implement the requirement: "ensure that only the legal combinations could be sold."

The creational patterns are for creating objects, not sellling them. So, the term "sold" is not appropriate and indicates something. Either way, A and D can certainly be used. And it is possible that they could be implemented using a Builder implementation or Prototype implementation as well. And, if a factory is not implemented, the the Builder pattern could certainly be implemented to satisfy the requirement.

"Correct" or "Incorrect" type answers for software design topics typically fail and are often misleading and assume false information. Design is subjective with many possibilities, and is very different than source code statements.
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Jimmy. This can be done with either pattern. I think some key words in the question are "legal combination". This may map to "family of related objects" from the Abstract factory pattern. I may be wrong but that's how I interpreted it.

-Mars
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe O'Toole wrote:Hi

I was hoping somebody might be able to help me with a question from javabeat:

Compact Computers is a small computer assembly company. Any customer currently has the following choices for a PC:



(i) 800 MHz processor, 40 GB HDD, 128 MB RAM

(ii) 1 GHz processor, 60 GB HDD, 256 MB RAM

(iii) 1.2 GHz processor, 80 GB HDD, 512 MB RAM



The use of what design pattern would ensure that only the legal combinations could be sold?



A Factory Method

B Builder

C Prototype

D Abstract Factory

E Singleton



Choice D is correct.



To me this is a perfect fit for the builder pattern. Interested to see what other folks think

Thanks
Joe


This is so weird question, not even illustrative.
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I do agree Builder pattern makes sense, since this requires to follow a algorithm to create a common production in multiple steps.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An implementation of the Factory Method or Abstract Factory can include a implementation of the Builder pattern. They are all Creational patterns and are complimentary.

A factory can also be passed a Prototype instance to help it create the correct object. The only pattern on the answer options which should never be used to do anything is the Simpleton. A,B,C, and D is the correct answer. But I doubt the test author could understand that
 
Leonardo De Stefano
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think, that this is because the question said: "ensure that only the legal combinations could be sold".

The builder patter would be more apropiate if you could build computers with any combination of those components.

But because the question ask for "only the legal combinations could be sold" then the Abstract Factory its more appropriate.

All are computers but you would have 3 implementations.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic