I failed to recognize any structural pattern in what they call Flyweight. To me it sounds like a simple tip from the world of relational databases. That is, a mechanism of foreign keys.
Designing and implementing your classes only by using composition is the same as having no normal form in your database. It's simply wrong and nobody does it this way anyway. Sort of: "Favor aggregation to composition when you deal with large number of objects from a finite sharable pool of value objects". It can be rephrased as: "Consider using caching factories". The latter in its nature sounds like it could be a chapter straight from Bloch's Effective Java. You know, sort of that double-edged sword from Fowler's Refactoring. Split into methods... Combine into one method... Just in our case we talk about a tradeoff between search time and storage space.
Maybe Flyweight is about the signature of operations, that now take Context parameter? But no, it has its own name "Strategy".
I really don't get it.
Aucun commentaire:
Enregistrer un commentaire