Question

I'm a non native English speaker, and trying to grasp a better understanding of that design pattern, I'm interested in the origin of that word for naming a pattern. What are the motivations for that name?

As far I know the flyweight design pattern is concerned with a way to support large number of fine-grained objects using sharing.

However, the definitions I'd found for that specific word (flyweight) refers to the boxing category of weight of less than 112 pounds.

So, why the pattern is called in this way?

Sorry if this seems foolish, but I really have no clue.

Was it helpful?

Solution

Flyweight is a boxing category, for light weight people.

Flyweight pattern is for "light weight" objects (though many of them).

OTHER TIPS

Lightweight -- or flyweight -- suggests that the classes created implement as little code (and hold as little data) as possible to do their job.

Creating (and instantiating, and passing them around) and maintaining them is therefore easier --like lifting a basically empty box.

This in contrast to a heavyweight class that may wrap a lot of data and comprise a lot of code.

The flyweight pattern is used to minimize the amount of memory used when you need to create a large number of similar objects. It accomplishes this by sharing instances.

The name derives from the weight classification as you mention but refers to the little amount of memory. That is, memory = weight.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top