aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Builder vs Abstract Factory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Builder vs Abstract Factory" Watch "Builder vs Abstract Factory" New topic
Author

Builder vs Abstract Factory

Joe O'Toole
Ranch Hand

Joined: Mar 02, 2009
Posts: 51
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

Joined: Apr 16, 2008
Posts: 2187
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

Joined: May 31, 2005
Posts: 528

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


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA

Live life to an interface, not an implementation!
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 845
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.


SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 845
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

Joined: Apr 16, 2008
Posts: 2187
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

Joined: Jan 31, 2002
Posts: 5
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Builder vs Abstract Factory