Pattern of the week: Flyweight
This weeks pattern is the FlyWeight Pattern. We will spend this week reviewing this pattern, how it is used and what its intent is for. For some more indepth definition you can seeandare some usful descriptions, but to appriciate this we will review the intent and possible solutions and applications for this pattern in everyday work.
Here is the intent of the flyweight pattern: “The intent of this pattern is to use sharing to support a large number of objects that have part of their internal state in common where the other part of state can vary.”
Example application for this pattern has been a text editor abstracting out the state of each character as glyphs. This is a nice concept but really limits the true application for this pattern across the board. When I see this pattern I think caching and this is also very similar to a connection pooling type of resource manager. I think the big difference here is these share some state while other parts are unique making each type a potential hybrid. This week in exploring this pattern think about applications for it. What interesting applications can you think of for this pattern, it seems with the advent of large memory and fast processors this hasn’t been considered except in memory condious applications with limited resources.