This design pattern is useful when you can separate the construction of an object from its representation. This allows for multiple options in the creation of the object.
Back
When is using the facade design pattern useful?
Front
This design pattern is useful when you have a single class that represents an entire subsystem. The client gives all the inputs and then all the operations are taken care of behind the scene. It represents the transactional boundary.
Back
When is using the flyweight design pattern useful?
Front
This design pattern is useful when you need a fine grained instance for efficient sharing.
This design pattern is useful when you need to sequentially access the elements of a collection.
Back
When is using the adapter design pattern useful?
Front
This design pattern is useful when you need to match interfaces from different classes.
Back
What is an example of using the builder design pattern?
Front
This design pattern could be used when building a multi-course dinner which includes:
- Drinks
- Starters
- Main Course
- Desert
There are multiple ways people could organize the dinner with any combination of 1 to 4 parts.
Back
What are advantages of using the facade design pattern?
Front
Advantages of this design pattern are:
- Reduce network calls
- Reduce coupling
Back
What is an example of using the decorator design pattern?
Front
This design pattern could be useful when:
- Managing types of pizza. There could be 10 types of pizza with 3 types of toppings (30 classes).
- Adding a discount to an order.
Back
What is an example of using the observer design pattern?
Front
online bidding
Back
When is the singleton design pattern useful?
Front
This design pattern is useful when you have a class of which only a single instance can exist.
Back
What is an example of using the prototype design pattern?
Front
This design pattern should be used in a chess game for the initial setup. Instead of generating the initial setup every time, initialize the game once and clone that instance whenever a game needs to restart.
Back
When is using the state design pattern useful?
Front
This design pattern is useful when the behavior of an object needs to change when its state changes.
This design pattern is useful when you need to notify many classes of a change in one class. The two important parts are registration and notification.
Back
What should you be aware of when creating singletons?
Front
- Constructor should be private
- Build with an enum (in Java, what about Typescript?)
Back
When is the prototype design pattern useful?
Front
This design pattern should be used if you have a fully initialized instance that needs to be copied or cloned.
Back
What is an example of using the iterator design pattern?
Front
This design pattern could be used for next and previous buttons on a remote control.
Back
What is an example of using the strategy design pattern?
Front
[Different sorting algorithms]
Back
When is using the visitor design pattern useful?
Front
Restrict users from editing the code API, but extending it
Back
What is an example of using the facade design pattern?
Front
This design pattern could be used for:
- Event Manager
- Online Book ordering
Back
What is an example of using the singleton design pattern?
Front
This design pattern could be used for a president of a country. There can only be one president at a time.
Back
What are patterns and architecture in JavaScript and TypeScript?
Front
1. Promise-based web architecture
2. Modularizing project
3. Asynchronous patterns.
Back
What is an example of using the proxy design pattern?
Front
This design pattern could be useful when managing a debit card (the proxy for a bank account). The real object is the bank account.
Back
What is an example of using the factory design pattern?
Front
This design pattern could be useful for creating people, which have extended classes of male and female.
Back
When is the proxy design pattern useful?
Front
This design pattern is useful when you have an object representing another object. This design pattern is able to hide complexity.
What is a disadvantage of using the decorator pattern?
Front
- Higher complexity creating objects
Back
What is an example of using the flyweight design pattern?
Front
This design pattern could be used for:
- Public switched telephone network. Efficiently manage a network of 1000 users and 10 lines since all users will not use the lines at the same time.
- Connection Pools
Back
What are patterns and architectures in JavaScript and Typescript?
Front
1. Promise-based web architecture
2. Modularizing project
2. Asynchronous patterns
Back
What is the difference between a behavioral design pattern and a continuous behavioral design pattern?
Front
[answer]
Back
When is using the decorator design pattern useful?
Front
This design pattern is useful when we want to add responsibilities to objects dynamically (at run time). This approach can be used instead of inheritance, where responsibilities are added statically.
Back
What is an example of using the chain of responsibility design pattern?
Front
This design pattern could be used for:
- Exception handling system. The system looks for a try catch block by going backwards in the code.
- Loan Approval process. Each person with higher level has a little more power to adjust the loan.
Back
When is using the strategy design pattern useful?
Front
This design pattern is useful when you need to encapsulate an algorithm within a class.
Back
What is a disadvantage of using the decorator pattern?
Front
Back
What are the benefits of using the builder design pattern?
Front
- Code is easier to read
- Simplifies the creation process
Back
What are the types of continuous behavioral design patterns?