Use sharing of data to support large number of fine grained objects effectively

  1. Flyweight

  2. Mediator

  3. Momento

  4. Bridge


Correct Option: A

AI Explanation

To support a large number of fine-grained objects effectively, we can use the concept of sharing data. This means that instead of each object having its own copy of data, they can share a common data structure. This helps in reducing memory usage and improving performance.

Among the given options, the design pattern that supports sharing of data effectively is the Flyweight pattern.

Option A) Flyweight - This option is correct because the Flyweight pattern is specifically designed to efficiently support a large number of fine-grained objects by sharing data. It achieves this by separating the intrinsic (shared) state and extrinsic (non-shared) state of objects. The intrinsic state is shared among multiple objects, while the extrinsic state is unique to each object.

Option B) Mediator - This option is incorrect because the Mediator pattern is used to define an object that encapsulates communication and coordination between multiple objects. It is not directly related to sharing data among objects.

Option C) Memento - This option is incorrect because the Memento pattern is used to capture and restore an object's internal state. It is not directly related to sharing data among objects.

Option D) Bridge - This option is incorrect because the Bridge pattern is used to decouple an abstraction from its implementation, allowing them to vary independently. It is not directly related to sharing data among objects.

Therefore, the correct answer is Option A) Flyweight, as it supports the sharing of data to effectively handle a large number of fine-grained objects.

Find more quizzes: