I received several questions on how to pick a Design Pattern, which motivated me to write this post. As it was mentioned in the Design Patterns overview article, there is no rule of thumb in selecting a Design Pattern. Developers should not choose a design pattern and design a solution around it. Instead they need to analyze at a higher level, the problem they are attempting to solve and pick a Design Pattern that is most appropriate.
I put together a quiz that has set of use cases that can represent a situation or a problem along with the possible Design Patterns that can be used to solve the problem. Remember that there is no one correct answer to these questions, but one Design Pattern is more appropriate than other choices.
Before you take the quiz, I encourage you to review the articles in the Design Pattern series. Good luck!
Question 1 You are creating an application that simulates a technical support service provider. All requests are initially handled by Level 1 support and are escalated to higher levels as and when required. |
|
Question 2 You are enhancing an existing application in a pizza shop. The price of the pizza depends on the options selected by the user. Each option carries a different additional price. There are a large number of options available (ex: extra cheese, type of crust, toppings and so on) |
|
Question 3 You are creating an application that needs functionality for logging. You need to implement a logger and log information into a file. |
|
Question 4 You are creating an encryption tool that supports different types of encryption (Ex: Triple-DES, MD5 etc) that encrypts data using different techniques. |
|
Question 5 You are creating an application that simulates the following scenario. A customer walks into a car dealer who provides customers with cars of any make and model, and requests for a car. The dealer passes this request on to different manufacturers. The dealer hands over the keys as soon as the manufacturing is completed. |
|
Question 6 You are creating a alert system that integrates with your existing application. Alerts can be triggerred from anywhere in the application. You will need to track the number of alerts sent for reporting purposes. |
|
Question 7 You are developing an application that supports sorting using different algorithms. You need to ensure that adding a new algorithm is simple. |
|
Question 8 You are working on an Applicant System. Different personnel can choose to be notified when an applicant successfully completes a phone interview. The personnel would create appropriate documentation so that the company is prepared when the applicant has a face to face interview. |
|
Question 9 You are integrating a 3rd party mailing system with an existing system. The 3rd party system expects the email addresses in a format that is different from the existing system can provide. You need to create a "wrapper" to make the incompatible systems work together. |
|
Question 10 You are working on a system that simulates the behavior of a printer. The printer has different modes - Warming up, Printing, Ready and Out of paper. There are several rules that determine what the subsequent mode can be. Ex: Cannot be switched from Out of paper mode to the Printing mode without being Ready. |
|
Question 11 You are creating an ecommerce application that has three distinct steps. Each step involves 1 complex subsystem. You need to hide the details of the subsystems and provide an interface for the client. |
|
Question 12 You are creating an application to determine the file/folder size. A folder can have 0 or more sub folders and it's size would be the size of the subfolders and the size of files (if any). |
|
Question 13 You are creating an application that simulates the behavior of a restaurant. When guests are ready to order, the waiter takes the order, indicates to the chef in the kitchen on what needs to be prepared. The chef prepares the item(s) in the order and the waiter serves the guests. |
|
Question 14 You are creating an application that simulates the behavior of a RSS feed. Interested users subscribe to the feed. As and when a new item appears in the blog, all interested users are notified. |
|