Search
01 SEP 2014

Growing with GS Collections

Kristen, a developer in our JVM Architecture team, shares how learning to code in GS Collections has improved her Java skills and better positioned her for the future.  

How did learning GS Collections change your coding style?

Kristen: GS Collections totally revamped my perception of Java. The RichIterable methods, such as collect, select, and reject, were completely foreign to me, but they were so intuitive, due to their common sense naming conventions, that it was easy to pick up. It never occurred to me how the power of collections can really make a difference in a programmer’s life, not only through efficiency, but also readability. Back at school, we were constantly being told to make our code as readable as possible. With GS Collections, it's practically a guarantee that using the framework ensures readable code.

What have been your most recent contributions to GS Collections?

Kristen: My most recent contribution to GS Collections was the addition of a SortedBag container. The GS Collections Bag pairs each object in the bag with its number of occurrences. A SortedBag allows for ordering of these objects, either by natural order if no parameters are given, or by any order specified by the user. TreeBag, the implementation of the SortedBag interface, delegates to a TreeSortedMap to maintain both the map-like quality of a bag along with the ability to sort. Here is a code example of the usefulness of a SortedBag:

In this example, the SortedBag keeps the sorted order of the customer's purchases so that finding something is simple.

You can find out more about SortedBag and BiMap in the version 4.2 release notes for GS Collections on GitHub.

How do you think GS Collections has and will impact your career as a software developer?

Kristen: After a fun summer experiencing GS Collections, my first assignment as a new analyst was something a little different. I was given a project for an app that our team created and manages.  The catch, however, was that it was written in Scala. My undergrad classes provided me with a very strong Java background. The thought of learning Scala seemed daunting to me. I had a look at the code, and began slowly editing and altering the codebase. As I started working, I realized that Scala was not as scary as I thought it would be. Sure, it was a new language, with a different syntax than my beloved Java (no semicolons!), but the framework was similar to GS Collections. Scala’s “filter” was essentially GS Collections “select.” There were many other similarities that I came across, and much sooner than I expected, I was becoming very familiar with Scala. And I have GS Collections to thank for that!