Compact Computers is a small computer assembly company. Its 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 Customers choose parts and quantities during the order. For example, a customer could choose a second HDD as a secondary hard drive or purchase additional RAM. What design pattern may be optimal for implementing a suitable design here?

  1. Factory Method

  2. Prototype

  3. Singleton

  4. Template Method

  5. Business Delegate

  6. Builder


Correct Option: B

AI Explanation

To answer this question, let's go through each design pattern option to understand why it is correct or incorrect:

A) Factory Method - The Factory Method pattern is used to create objects of a specific type. In this scenario, the Factory Method pattern may not be the optimal choice as it is more suitable for creating different types of objects based on a common interface or superclass.

B) Prototype - The Prototype pattern is used to create new objects by cloning existing objects. In this scenario, the Prototype pattern could be a suitable choice as it allows customers to select and customize their own PC accessories by cloning and modifying existing configurations.

C) Singleton - The Singleton pattern is used to ensure that only one instance of a class exists throughout the application. In this scenario, the Singleton pattern may not be the optimal choice as it does not directly address the requirement of allowing customers to pick and choose accessories for their PCs.

D) Template Method - The Template Method pattern is used to define the skeleton of an algorithm and allow subclasses to redefine certain steps of the algorithm without changing its structure. In this scenario, the Template Method pattern may not be the optimal choice as it focuses more on defining algorithms rather than allowing customers to pick and choose accessories.

E) Business Delegate - The Business Delegate pattern is used to decouple the client code from the implementation details of the business service. In this scenario, the Business Delegate pattern may not be the optimal choice as it does not directly address the requirement of allowing customers to pick and choose accessories for their PCs.

F) Builder - The Builder pattern is used to construct complex objects step by step. In this scenario, the Builder pattern could be a suitable choice as it allows customers to select and customize their own PC accessories by adding them one by one to build the final PC configuration.

Based on the given options, the most suitable design pattern for implementing the desired functionality is the Prototype pattern (Option B). This pattern allows customers to pick and choose accessories by cloning and modifying existing configurations.

Therefore, the correct answer is B) Prototype.

Find more quizzes: