You could, therefore, view the Prototype pattern simply as one way to alleviate the code redundancy often introduced by the Factory Method pattern. Flyweight method is a Structural Design Pattern that focus on minimizing the number of objects that are required by the program at the run-time. This type of design pattern comes under structural pattern as this pattern provides ways to decrease object count thus improving the object structure of application. This means that they cannot be modified once they have been constructed. With a type object, the goal is to minimize the number of classes you have to define by lifting “types” into your own object model. Now instead of storing the same data in multiple objects, it’s kept in just a few flyweight objects and linked to appropriate Tree objects which act as contexts. The stained glass canopy of leaves fragments the sunlight into golden shafts of mist. When no matching object is found, an existing similar kind of objects can be reused by flyweight pattern. By using the design patterns you can make your code more flexible, reusable and maintainable. Flyweight Pattern. Advantage of design pattern: The Flyweight pattern describes how to share objects to allow their use at fine granularity without prohibitive cost. To apply flyweight design pattern, first we will divide state (class members) of our Class into two different types based on following criteria :- The Flyweight pattern is purely about efficiency. Understand the Tradeoffs of the Flyweight Pattern The main purpose of Flyweights is to save space (memory). In programming languages, some times you may need to generate a very large number of small class instances to represent the entire system. It is created in such a fashion that you can not distinguish between an object and a Flyweight Object. So that every object consumes memory space that can be crucial for low memory devices. Each "flyweight" object is divided into two pieces: the state-dependent (extrinsic) part, and the state-independent (intrinsic) part. Benefits of the MVC pattern. III. Let’s consider a second example; you might have played Angry Birds game. Flyweight design pattern is an example of Structural design pattern as it reduce number of objects counts thus changing the structure of the Application. A Flyweight Pattern says that just "to reuse already existing similar kind of objects by storing them and create new object when no matching object is found". It is generally useful to minimize the usage of memory and increase performance. Ancient hemlocks, countless in number, tower over you forming a cathedral of greenery. The Flyweight Design Pattern is used when we want to create large number of similar object. Intrinsic state is stored (shared) in the Flyweight object. When to use Factory Design Pattern? ... Flyweight pattern is basically used to reduce the number of objects created and used in the application. Summary. Although performance/memory tradeoffs are a classic issue in program optimization, most of the time the impact on performance of using a Flyweight is negligible, especially if the objects are naturally immutable. Factory Design Patterns is the pattern that recommends creation of separate Factory Object for creation of other object. One important feature of flyweight objects is that they are immutable .