Design Patterns and Frameworks – Flyweight
Oliver Haase
Oliver Haase Emfra — Flyweight 1/12
Design Patterns and Frameworks Flyweight Oliver Haase Oliver Haase - - PowerPoint PPT Presentation
Design Patterns and Frameworks Flyweight Oliver Haase Oliver Haase Emfra Flyweight 1/12 Description Classification : Object-based structural pattern Purpose : Use small-grained objects together, to avoid instantiation of a
Oliver Haase Emfra — Flyweight 1/12
Oliver Haase Emfra — Flyweight 2/12
Oliver Haase Emfra — Flyweight 3/12
Oliver Haase Emfra — Flyweight 4/12
◮ An application uses a large number of objects. ◮ The memory consumption forbids instantiation of individual
◮ A big part of the object state can be moved into the context
◮ Removal of the extrinsic state results in a small number of
◮ Thr application does not depend on the object identity. Oliver Haase Emfra — Flyweight 5/12
Oliver Haase Emfra — Flyweight 6/12
◮ implements the Flyweight interface ◮ keeps the intrinsic state of the (shared) object
◮ has references to the flyweight objects ◮ keeps or computes the objects’ extrinsic state Oliver Haase Emfra — Flyweight 7/12
Oliver Haase Emfra — Flyweight 8/12
◮ degree of reduction of objects; ◮ size of intrinsic state; ◮ whether extrinsic state is stored or calculated. Oliver Haase Emfra — Flyweight 9/12
Oliver Haase Emfra — Flyweight 10/12
Oliver Haase Emfra — Flyweight 11/12
Oliver Haase Emfra — Flyweight 12/12