Design Patterns MCQs

Design patterns are proven solutions to common software design problems. They provide a template for writing code that is more flexible, reusable, and easier to maintain. Some well-known design patterns include Singleton, Factory, Observer, and Strategy, each addressing specific challenges in software design.
halo_section_image

1. Which use-case would you consider is appropriate for MVC? 1. Storing and updating in-game Currency. 2. Having different types of characters. 3. For adding elements to the game over time. 4. Creating skins for any elements in game

2. Why is a Service class used for a gameObject? 1. It is responsible for the creation of gameObject. 2. To interact with other services. 3. It holds references for MVC classes to perform operations on them.

3. What is the responsibility of Model in MVC? 1. Holding all the data relevant to the gameObject. 2. Model communicates directly with View to carry out logic. 3. Adding or Retrieving data.

4. Where are the events supposed to be created inside an MVC-S design pattern?

5. What does MVC stand for?

6. When the deadline for the coding assignment is only 2 days, how will you prioritize design patterns and code architecture for it?

7. How does the Command Pattern encapsulate method invocations?

8. In context of Command Pattern, what does the object requesting the action needs to know?

9. In the Command Pattern, what does the term "Abstract Command" represent?

10. What is the responsibility of the Command Invoker in the Command Pattern?

11. Who invokes the actual actions (e.g., Action1() and Action2()) in the Command Pattern?

12. Why is the WillHitTarget() method moved to the UnitCommand class from the IAction class?

13. When implementing the Undo feature, why should each command class have an Undo() method that knows how to reverse its action?

14. Can the Command Pattern be used for implementing undo and replay features in non-deterministic game engines?

15. Can the Command Pattern be used for implementing undo and replay features in games with continuous gameplay?

16. The Model in an MVC architecture is responsible for:

17. The View in an MVC architecture is responsible for:

18. The Controller in an MVC architecture is responsible for:

19. Can you identify a scenario where applying MVC to a project might be over-engineering?

20. How can improper communication protocols between MVC components lead to issues in software development?

1. Which use-case would you consider is appropriate for MVC? 1. Storing and updating in-game Currency. 2. Having different types of characters. 3. For adding elements to the game over time. 4. Creating skins for any elements in game

A. 1,2,3

B. 2,3,4

C. 2,3

D. 1,3,4

2. Why is a Service class used for a gameObject? 1. It is responsible for the creation of gameObject. 2. To interact with other services. 3. It holds references for MVC classes to perform operations on them.

A. 1,2

B. 2,3

C. 1,3

D. All of the above.

3. What is the responsibility of Model in MVC? 1. Holding all the data relevant to the gameObject. 2. Model communicates directly with View to carry out logic. 3. Adding or Retrieving data.

A. 1,2

B. 1,3

C. All of the above

D. None of the above.

4. Where are the events supposed to be created inside an MVC-S design pattern?

A. Inside the Service.

B. Inside the Model.

C. Inside the Controller.

D. Inside the View.

5. What does MVC stand for?

A. Model-View-Component

B. Model-Value-Component

C. Model-View-Controller

D. Model-Value-Controller

6. When the deadline for the coding assignment is only 2 days, how will you prioritize design patterns and code architecture for it?

A. As the deadline is too strict, I will only do the implementation properly and will not worry about the quality of the code.

B. No matter what is the deadline, I will try the best code of my life. I will ask for some buffer days if I am not able to manage the deadline but I will not compromise on code quality.

C. I will skip the assignment because the deadline is too strict and there is no point in submitting the rushed code.

7. How does the Command Pattern encapsulate method invocations?

A. It separates the client, receiver, and action itself, by representing actions as objects.

B. It uses encryption to secure method calls.

C. It stores method invocations in a command history.

D. It creates a separate class for each method.

8. In context of Command Pattern, what does the object requesting the action needs to know?

A. All details of method execution.

B. How to execute the action itself.

C. The encapsulated request to execute.

D. Nothing at all

9. In the Command Pattern, what does the term "Abstract Command" represent?

A. The actual action to be executed.

B. A template for encapsulating an Execute() call.

C. The client's request to the invoker.

D. The concrete implementation of a command.

10. What is the responsibility of the Command Invoker in the Command Pattern?

A. It creates specific implementations of commands.

B. It triggers the execution of commands and manages them.

C. It carries out the actual actions associated with commands.

D. It acts as the client in the pattern.

11. Who invokes the actual actions (e.g., Action1() and Action2()) in the Command Pattern?

A. The Client

B. The Command Invoker

C. The Concrete Command

D. The Receiver

12. Why is the WillHitTarget() method moved to the UnitCommand class from the IAction class?

A. To ensure consistent results when executing the same command

B. To increase code modularity

C. To simplify the implementation of IAction

D. To make the code more readable

13. When implementing the Undo feature, why should each command class have an Undo() method that knows how to reverse its action?

A. To complicate the codebase and add redundancy.

B. To enable players to undo multiple actions simultaneously.

C. To ensure that the Undo feature works seamlessly with all unit actions.

D. To store a history of commands in a separate registry.

14. Can the Command Pattern be used for implementing undo and replay features in non-deterministic game engines?

A. Yes, by recording and replaying individual player actions just like in deterministic engines.

B. Yes, by periodically taking snapshots of the game state to provide some level of consistency.

C. No, the Command Pattern is not suitable for non-deterministic game engines.

D. Yes, by creating branching timelines to account for the multiple possible outcomes.

15. Can the Command Pattern be used for implementing undo and replay features in games with continuous gameplay?

A. Yes, by storing player actions as command objects and replaying them in the same order as they were originally executed.

B. No, the Command Pattern is only suitable for games with discrete gameplay, and it cannot handle continuous gameplay.

C. Yes, by employing a time-stamped command queue to maintain the sequence of actions for replay.

D. Yes, as long as you have a Time-Traveling Unicorn

16. The Model in an MVC architecture is responsible for:

A. Rendering graphics and handling user interface elements.

B. Managing the data and business logic of the application.

C. Processing user inputs and corresponding events.

D. Coordinating between the View and Controller components.

17. The View in an MVC architecture is responsible for:

A. Managing the application's data and logic rules.

B. Rendering the user interface and presenting data to the user.

C. Directly handling user inputs and interactions.

D. Storing and retrieving application data from a database.

18. The Controller in an MVC architecture is responsible for:

A. Storing and managing application data.

B. Rendering user interface components and graphics.

C. Handling the input, processing user interactions, and making calls to Model objects.

D. Ensuring the data integrity and security of the application.

19. Can you identify a scenario where applying MVC to a project might be over-engineering?

A. A solo developer participating in a weekend game jam, creating a simple, small-scale game, Flappy Bird clone.

B. A developer working on a card game with multiple cards with different looks and functionalities.

C. A team developing a narrative-driven RPG with extensive dialogue trees, character customisation, and dynamic world-building, requiring careful separation of game mechanics, story progression, and UI.

D. An indie studio working on a tower defence game with many different troops.

20. How can improper communication protocols between MVC components lead to issues in software development?

A. By improving code readability and organization, leading to more efficient development processes.

B. By increasing code coupling and dependency, making it difficult to isolate and modify individual components.

C. By simplifying debugging and troubleshooting, resulting in faster resolution of software issues.

D. By reducing the need for frequent updates and modifications, ensuring stability and reliability of the software product.

Introduction to Design Patterns

Design patterns are the best and most reusable practices used by experienced object-oriented developers. These patterns provide a procedural solution to solve a common problem and reduce the complexities in your code.


Advantages of Design Pattern

The main advantages of the design patterns are as follows:

  1. Reusability
  2. Maintainability
  3. Scalability
  4. Improved Communication
  5. Enhanced Code Quality

This design pattern MCQs is curated to test your knowledge on the topic.