aspose file tools*
The moose likes Beginning Java and the fly likes What is a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is a "first class collection"?" Watch "What is a "first class collection"?" New topic
Author

What is a "first class collection"?

Stevens Miller
Ranch Hand

Joined: Jul 26, 2012
Posts: 396
    
    2

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

Joined: Mar 05, 2008
Posts: 2970
    
    9
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
Ranch Hand

Joined: Jul 26, 2012
Posts: 396
    
    2

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is a "first class collection"?
 
Similar Threads
Converting an application to Java (new to Java)
Regarding Collections
what is your opinion of objects ?
Memory accocation in case of arrays