You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Joe Bloggs has to create a class to load a huge configuration file. There can be memory issues if the file is loaded multiple times. If there are multiple instances, there can also be inconsistencies. Which design pattern can he use?
Factory
Builder
Singleton
Prototype
Which implementation of the Singleton pattern is used in the following code snippet?
Joe Bloggs is developing a complex configuration object for a software system. The configuration object has over 60 properties, and creating instances of it using a traditional constructor has become unwieldy and error-prone. Additionally, the configuration objects should be immutable to ensure consistency throughout the application. Which design pattern should Joe use to address these challenges?
Factory
Builder
Singleton
Prototype
Joe Bloggs has to integrate Uber with different insurance providers. Each provider has a different set of APIs and data formats. He wants to just use one format in the codebase. Adding new providers should also be easy. What design pattern can he use?
Factory
Builder
Adapter
Facade
Joe Bloggs wants to implement a simulation application. You can add different layers such as brightness, hue, saturation, etc. You can also add different filters such as sepia, black and white, etc. What design pattern can he use to implement this?
Factory
Decorator
Adapter
Builder
Answers
Singleton (C)
Lazy initialization (A)
It is not thread-safe (B)
Eager initialization (B)
It does not allow dynamic initialization i.e. pass arguments to the constructor (D)