What is Inversion of Control?

  • A mechanism for managing dependencies between software components, such as libraries or services, that are required to run an application.
  • A method of testing in which dependencies are replaced with mock objects to isolate the test subject from the rest of the system.
  • A software design principle in which the flow of control of a system is inverted compared to the traditional approach. Instead of the system calling a component to perform a task, the component is notified when a task is ready and performs it. This leads to a more flexible and decoupled system, allowing for easier maintenance and testing.
  • A technique for structuring software components into a tree-like hierarchy to organize dependencies and reduce coupling between components.
Inversion of Control is a design principle in which the flow of control in a system is inverted. Instead of a system calling components to perform tasks, components are notified when tasks are ready and perform them. This leads to a more flexible and decoupled system, allowing for easier maintenance and testing.

Name the actor classes used in Memento pattern.

  • Caretaker, Originator, Memento
  • Memento, Caretaker, Originator
  • Originator, Caretaker, Memento
  • Originator, Memento, Caretaker
The actor classes used in the Memento pattern are: Originator, Memento, and Caretaker. The Originator class is responsible for creating the memento and restoring its state. The Memento class is responsible for storing the internal state of the Originator. The Caretaker class is responsible for maintaining a list of mementos and providing the Originator with the appropriate memento at the appropriate time.

Give an example where Interpreter pattern is used?

  • Interpreter pattern is used in compilers, where expressions in a programming language need to be parsed and evaluated
  • Interpreter pattern is used in database management systems, where SQL queries need to be interpreted and executed
  • Interpreter pattern is used in game engines, where game rules need to be interpreted and executed
  • Interpreter pattern is used in web applications, where user requests need to be interpreted and processed
One example of where Interpreter pattern is used is in compilers, where expressions in a programming language need to be parsed and evaluated. The Interpreter pattern can be used to evaluate the syntax and semantics of a programming language, and generate code or perform other actions based on the results of the evaluation.

What is the Command and Query Responsibility Segregation (CQRS) Pattern?

  • A pattern in which read and write operations are separated into separate models.
  • A pattern that helps to avoid race conditions and deadlocks in multithreaded applications.
  • A pattern used to implement inter-process communication.
  • A pattern used to improve database performance by caching results in memory.
CQRS is a pattern that separates the responsibilities of querying data (read) from modifying data (write) into separate models, improving scalability and maintainability of the application.

What is Prototype pattern?

  • A design pattern that creates objects by cloning existing objects, rather than creating new instances from scratch
  • A design pattern that creates objects in a step-by-step manner, allowing for more control over the object creation process
  • A design pattern that helps to reduce the number of objects in the system, making it more efficient
  • A design pattern that promotes the loose coupling between objects, making the system easier to maintain and extend
Prototype pattern is a design pattern that creates objects by cloning existing objects, rather than creating new instances from scratch. This pattern involves implementing a prototype interface, which is used to create a new instance of the object. The new instance is a copy of the existing object, with any changes made to the copy not affecting the original.

What is the difference between the Adapter and Bridge patterns?

  • None of the above
  • The Adapter and Bridge patterns are the same
  • The Adapter pattern converts the interface of one class into another, while the Bridge pattern decouples an abstraction from its implementation, allowing the two to be varied independently
  • The Adapter pattern decouples an abstraction from its implementation, while the Bridge pattern converts the interface of one class into another
The Adapter pattern converts the interface of one class into another, while the Bridge pattern decouples an abstraction from its implementation, allowing the two to be varied independently

What is the difference between the Template patterns and the Strategy pattern?

  • Template patterns allow for the implementation of a specific algorithm to be swapped out at runtime, while Strategy patterns provide a set of steps to be followed in a defined order. Template patterns are meant to be composed, while Strategy patterns are meant to be subclassed.
  • Template patterns and Strategy patterns are the same thing.
  • Template patterns and Strategy patterns have no relationship to each other.
  • Template patterns provide a set of steps to be followed in a defined order, while Strategy patterns allow for the implementation of a specific algorithm to be swapped out at runtime. Template patterns are meant to be subclassed, while Strategy patterns are meant to be composed.
The Template pattern provides a set of steps to be followed in a defined order, while the Strategy pattern allows for the implementation of a specific algorithm to be swapped out at runtime. Template patterns are meant to be subclassed, while Strategy patterns are meant to be composed.

What are Design Patterns?

  • A coding style that emphasizes using a specific way of writing code to make it more maintainable and readable.
  • A design principle that focuses on creating software that is aesthetically pleasing and easy to use.
  • A methodology for software development that involves following a set of steps to develop software.
  • A set of predefined solutions to common problems in software development that provide a common vocabulary and a standard way of thinking about a particular problem.
Design patterns are reusable solutions to common problems that arise in software development. They provide a common vocabulary and a standard way of thinking about a particular problem, making it easier for software developers to communicate and collaborate. Design patterns are not specific to any programming language and can be applied to different programming paradigms, including object-oriented programming.

What is the purpose of the Command design pattern?

  • To create objects that are interchangeable with their base classes.
  • To encapsulate operations in an object and pass them as messages.
  • To manage the flow of control between objects in a complex system.
  • To provide a way to invoke operations without coupling the invoker object to the target object that performs the operation.
The Command design pattern decouples the invoker of an operation from the target object that performs the operation. This allows for greater flexibility and modularity in the design of a system.

What is Flyweight pattern?

  • A design pattern that allows objects with incompatible interfaces to work together by converting the interface of one object into an interface expected by the client
  • A design pattern that creates objects in a step-by-step manner, allowing for more control over the object creation process
  • A design pattern that provides a simplified interface to a complex system, allowing the client to interact with the system through a single, unified interface
  • A design pattern that uses shared objects to support large numbers of similar objects efficiently
Flyweight pattern is a design pattern that uses shared objects to support large numbers of similar objects efficiently. The pattern involves creating a shared object that can be used by multiple clients, reducing the amount of memory required to store the objects. This pattern can be useful in situations where you need to create large numbers of similar objects, but you want to minimize the memory footprint of the application.