• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is a "first class collection"?

 
Stevens Miller
Bartender
Posts: 1241
24
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to do the Object Calisthenics exercise, which requires writing a thousand-line Java application in strict compliance with nine rules. Rule Four is this:
First class collections
Application of this rule is simple: any class that contains a collection should contain no other member variables. Each collection gets wrapped in its own class, so now behaviors related to the collection have a home. You may find that filters become a part of this new class. Also, your new class can handle activities like joining two groups together or applying a rule to each element of the group.

The body of the rule is easy enough to understand ("any class that contains a collection should contain no other member variables"), but what does "First Class collections" mean? Of course I've searched on this phrase, but most of what I'm finding seems to trace back to the Object Calisthenics exercise in some way, or to one of those questions you tend to find on stackoverflow that somehow goes kind of viral and ends up being repeated on a hundred different sites (probably because no one was able to answer it to the OP's satisfaction).

Wikipedia offers some help, but it doesn't really seem to relate to the body of the rule as written above.

What's a "first class collection" in Java?

Thanks.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it means anything in Java. It's probably a term devised by the Object Calisthenics author. Or perhaps someone else. But regardless, there's no standard understanding of what the term is supposed to mean. Not in the mainstream Java community, anyway.
 
Stevens Miller
Bartender
Posts: 1241
24
C++ Java Netbeans IDE Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Mike. My impression is that you are correct. Kind of disappointing that they use it without explaining their meaning. I'll e-mail the authors and post any replies I get.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic