11. Design Pattern: Flyweight

<p>It is one of the&nbsp;<strong>structural design patterns</strong>&nbsp;that is used to reduce the number of objects created to improve the&nbsp;<strong>memory footprint</strong>&nbsp;of an application. It is usually employed whenever we have limited memory or we can&nbsp;<strong>reuse the already existing similar kind</strong>&nbsp;of objects. It also helps in improving performance.</p> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:640/0*D9CS6Ptv8DJAPD_R" style="height:400px; width:640px" /></p> <p>Let&rsquo;s take an example of an application where the Flyweight pattern can be applied to improve its memory footprint.&nbsp;<strong>Notepad++, A Text Editor</strong>&nbsp;which we want to implement. For simplicity, Assume we can write anything in the notepad++ using&nbsp;<code>A-Z</code>,&nbsp;<code>a-z</code>, and&nbsp;<code>0&ndash;9</code>,&nbsp;<code>space</code>&nbsp;characters.</p> <p>A Client writes a paragraph using the mentioned characters. The same character would be repeating a couple of times. Can we create an object for those characters just once in the first use and reuse the same object in future uses?</p> <p><a href="https://levelup.gitconnected.com/11-design-pattern-flyweight-bf3fbc41fa8c"><strong>Read More</strong></a></p>
Tags: Design Pattern