Multiple choice technology architecture

Suppose I have to code a program to draw 1000 circles with 6 different colors – Which Structural Pattern approach would help?

  1. Façade.

  2. FlyWeight.

  3. Decorator.

  4. Adpater

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The Flyweight Pattern is specifically designed to minimize memory usage by sharing intrinsic state (common data like colors) among multiple objects. For 1000 circles with only 6 colors, Flyweight would share the 6 color objects rather than storing color with each circle, dramatically reducing memory. Facade simplifies interfaces, Decorator adds responsibilities dynamically, and Adapter converts interfaces - none optimize memory like Flyweight.