0

Comment in the TreeType example under Flyweight is ambiguous

Razvan-Adrian Ciochina 3 years ago 0
Under the flyweight pattern page the example has the following comment
// The flyweight class contains a portion of the state of a
// tree. These fields store values that are unique for each
// particular tree. ...

What I wanted to point out is that while this comment applies to the following declared data structure, the comment is actually referring to the fields in the flyweight class. My suggestion here is to separate the comment describing the object from the more general conceptual comment on the Flyweight pattern itself. This way when referring to "these fields" it's more clear that it's referring to the flyweight fields not the TreeType ones, which are referred to right in the next sentence: 

// For instance, you won't find here the tree
// coordinates. But the texture and colors shared between many
// trees are here.

This seems to contradict the first statement.