One code smell I sometimes see is duplicated data. One form of this is when I see many instances of the same class that all have the same values for several instance variables. To me, this is an indicator that I'm missing a class. Rather than repeat the same information in all those instances, I ask if there's some abstraction that binds those instance variables together. If it makes sense, separate that abstraction into a different class. This allows the original obects to reference one shared object and reduce the amount of memory required to store the instances. This technique uses the Flyweight design pattern. Flyweights extract common state into shared objects and can help reduce the memory requirements for an object model.
Download