Added 'Flyweight' pattern example: "Fowlweight".
I deviated from the example in the book for two reasons: I wanted to 'sort'
ducks as illustrated in the 'Template Method' pattern and since that illustration
sorted by 'weight' I thought naming the example 'Fowlweight' combined both the
pattern and its intent. Since I deviated, I felt obligated to write a narrative
in the same tone as that used throughout the book. Here is my humble attempt:
"The number of birds migrating to Objective has overwhelmed the Quackologists
who are complaining that it is hard to keep up because the journaling program
you wrote is getting sluggish. Quackologists capture birds, categorize them,
weight them, tag them, and finally, record them with your program; however,
as the size of the flock grows your program begins to crawl. After hours of
drinking coffee at Starbuzz reviewing your design, you realize that some
traits are common to each type of bird; its type, the sound it makes and how
it swims. If only you could isolate the common (intrinsic) traits from the
unique (extrinsic) traits, its weight and tag number. Your redesign implements
the ‘Flyweight’ pattern by creating a single instance for each type of bird and
each bird contains a reference back to its type."
Log in to post a comment.