What is the difference between Façade and Mediator?

  • Façade and Mediator are the same thing.
  • Façade and Mediator have no relationship to each other.
  • Façade is a pattern for communication between components of a system, while Mediator is a simplified interface to a complex system. Façade is a two-way communication pattern, while Mediator is a one-way communication pattern.
  • Façade is a simplified interface to a complex system, while Mediator is a pattern for communication between components of a system. Façade is a one-way communication pattern, while Mediator is a two-way communication pattern.
The Façade pattern provides a simplified interface to a complex system, while the Mediator pattern provides a way for components of a system to communicate with each other in a loosely coupled manner. Façade is a one-way communication pattern, while Mediator is a two-way communication pattern.

What's the difference between the Dependency Injection and Service Locator patterns?

  • The Dependency Injection pattern involves a central registry that provides objects when requested, while the Service Locator pattern involves passing objects as dependencies to the objects that require them.
  • The Dependency Injection pattern involves creating and configuring objects, while the Service Locator pattern involves finding and returning objects.
  • The Dependency Injection pattern involves finding and returning objects, while the Service Locator pattern involves creating and configuring objects.
  • The Dependency Injection pattern involves passing objects as dependencies to the objects that require them, while the Service Locator pattern involves a central registry that provides objects when requested.
The Dependency Injection pattern involves passing objects as dependencies to the objects that require them, while the Service Locator pattern involves a central registry that provides objects when requested. The Dependency Injection pattern provides objects to its client as they are needed, while the Service Locator pattern allows objects to request objects they need from a centralized registry.

What is the Null Object pattern?

  • A creational design pattern that provides a way to instantiate an object in a superclass, but allow subclasses to alter the type of objects that will be created.
  • A design pattern used to ensure a class has only one instance, while providing a global access point to this instance for the entire system.
  • A software design pattern that enables an object to be passed around as a value.
  • The Null Object pattern is a behavioral design pattern that provides a default object as a representative of "null" in the context of design patterns.
The Null Object pattern is a behavioral design pattern that provides a default object as a representative of "null" in the context of design patterns.

What does program to interfaces, not implementations mean?

  • This means that when designing software, the focus should be on defining the behavior of the components, rather than the specific implementations of those components.
  • This means that when designing software, the focus should be on defining the data structures and algorithms used by the components, rather than the specific implementations of those components.
  • This means that when designing software, the focus should be on defining the input and output of the components, rather than the specific implementations of those components.
  • This means that when designing software, the focus should be on defining the interfaces between different components, rather than the specific implementations of those components. This makes the code more flexible and easier to maintain, as it reduces the amount of coupling between components.
This means that when designing software, the focus should be on defining the interfaces between different components, rather than the specific implementations of those components. This makes the code more flexible and easier to maintain, as it reduces the amount of coupling between components.

What is the purpose of the Decorator design pattern?

  • To attach additional responsibilities to an object dynamically.
  • To create objects that are interchangeable with their base classes.
  • To ensure that a class has only one instance and provide a global point of access to that instance.
  • To manage the flow of control between objects in a complex system.
The Decorator design pattern is used to attach additional responsibilities to an object dynamically. This allows for greater flexibility and modularity in the design of a system, as well as the ability to add or remove responsibilities as needed.

What is the difference between the Decorator and Flyweight patterns?

  • The Decorator pattern is used to dynamically add or override behavior of an object, while the Flyweight pattern is used to reduce the number of objects created by sharing objects that are costly to create.
  • The Decorator pattern is used to dynamically add or override behavior of an object, while the Flyweight pattern is used to share objects that are costly to create.
  • The Decorator pattern is used to reduce the number of objects created by sharing objects that are costly to create, while the Flyweight pattern is used to dynamically add or override behavior of an object.
  • The Decorator pattern is used to share objects that are costly to create, while the Flyweight pattern is used to dynamically add or override behavior of an object.
The Decorator pattern is used to dynamically add or override behavior of an object, while the Flyweight pattern is used to share objects that are costly to create.

What is Null Object pattern?

  • A design pattern in which a special object, called the null object, is used to represent the absence of a value, avoiding the need for explicit checks for null values
  • A design pattern in which an object, called the context, holds a reference to an instance of one of several possible concrete state objects, each of which represents a distinct state of the context and implements a common state interface
  • A design pattern in which an object, called the decorator, adds or overrides behavior of an existing object, dynamically
  • A design pattern in which an object, called the prototype, is used as a template to create new objects, without specifying their concrete classes
The Null Object pattern is a design pattern in which a special object, called the null object, is used to represent the absence of a value, avoiding the need for explicit checks for null values. The Null Object pattern is used to provide a default implementation of an interface, reducing the amount of error-prone null checks in the code. The Null Object pattern can also be used to simplify the code and reduce coupling by eliminating the need for explicit checks for null values.

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.

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.

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.

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.

What is the Visitor pattern?

  • A behavioral design pattern that lets you pass requests along a dynamic chain of receivers until one of them handles it.
  • A behavioral design pattern that separates an algorithm from an object structure on which it operates. The pattern allows you to define a new operation without changing the classes of the objects on which it operates.
  • A creational design pattern that uses factory methods to deal with the problem of creating objects without specifying the exact class of object that will be created.
  • A structural design pattern that allows you to compose objects into tree structures to represent part-whole hierarchies.
A behavioral design pattern that separates an algorithm from an object structure on which it operates. The pattern allows you to define a new operation without changing the classes of the objects on which it operates.