> Design Patterns > Flyweight Design Pattern
Flyweight design pattern is used to support sharing of objects when the objects are in large number with details to granularity of system.
The intent is to share the fine-grained objects to make the system efficient.
It looks good to have objects to the granularity of system as it gives flexibility in design but having large number of objects may make the system complex and affect the efficiency.
We can have the shared object called flyweight which can be used in multiple context. So we will identify what information is independent for object which is related to the object context. The object will have independent information so that it can be shared. The context information will depend on object context as it varies and will be provided by client. The independent information is called intrinsic state and context information is called extrinsic state. The operation of flyweight object will be done based on these states.
|C++||Flyweight Pattern in C++||Flyweight Pattern C++ Example|
|C#||Flyweight Pattern in C#||Flyweight Pattern C# Example|
|Java||Flyweight Pattern in Java||Flyweight Pattern Java Example|
|Python||Flyweight Pattern in Python||Flyweight Pattern Python Example|
|PHP||Flyweight Pattern in PHP||Flyweight Pattern PHP Example|
|Ruby||Flyweight Pattern in Ruby||Flyweight Pattern Ruby Example|
|Swift||Flyweight Pattern in Swift||Flyweight Pattern Swift Example|
|Objective-C||Flyweight Pattern in Objective-C||Flyweight Pattern Objective-C Example|