Freigeben über


Object Calisthenics: Rule 8: Use first class collections

Yet another rule to keep your objects focused at a single responsibility. Any class with an instance variable that is a collection should have no other instance variables. When I first tried object calisthenics this was actually easier said than done. Having a collection and some other instance variable made sense a few times, but once I wrapped the collection into a separate class I actually ended up with less code duplication.