skip to Main Content


Say hello to the toggle bar. This is an optional section you can use to display any content you'd like. Simply select a page from the theme panel and the content of the page will display here. You can even use the drag and drop builder to create this! This is a perfect place for your company mission statement, alerts, notices or anything else.

Get In Touch

Phone: 1-800-Total-Theme
Address: Las Vegas, Nevada

Our Location


Flyweight Pattern

Post Series: Structual Design Pattern

Flyweight pattern is used to reduce the number of objects created, to decrease memory and resource usage. As a result it increase performance.

  1. Flyweight is used when there is a need to create a large number of objects of almost similar nature and storage cost is high.
  2. A few shared objects can replace many unshared ones.
  3. Most of the state can be kept on disk or calculated at runtime.

Intrinsic data is held in the properties of the shared flyweight objects. This information is stateless and generally remains unchanged, if any change occurs it would be reflected among all of the objects that reference the flyweight.

Extrinsic data is computed on the fly means at runtime and it is held outside of a flyweight object. Hence it can be stateful.


Flyweight: This is an interface which defines the members of the flyweight objects.
ConcreteFlyweight: This is a class which Inherits from the Flyweight class.
UnsharedFlyweight: This is a class which Inherits from the Flyweight class and enables sharing of information, it is possible to create instances of concrete flyweight classes that are not shared.
FlyweightFactory: This is a class which holds the references of already created flyweight objects. When the GetFlyweight method is called from client code, these references are checked to determine if an appropriate flyweight object is already present or not. If present, it is returned. Otherwise a new object is generated, added to the collection and returned.



Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top