The Eclipse Collections Code Katas
Learn the Eclipse Collections library by completing hands-on Java code katas.
We learn best by doing
What is Eclipse Collections?
Eclipse Collections is an open source Java collections library. Eclipse Collections has been evolving as a Java library since 2004. It was first released into open source as GS Collections in January 2012. It was later moved to the Eclipse Foundation in December 2015 and became Eclipse Collections.
You can read more about the history of GS Collections and its move to the Eclipse Foundation in the following article in InfoQ.
GS Collections Moves to the Eclipse Foundation
The Eclipse Foundation and Goldman Sachs have announced a joint venture, moving the popular GS Collections open source…
What are the Eclipse Collections Katas?
The Eclipse Collections Katas are structured exercises organized into individual kata modules that will help you learn the Eclipse Collections library. There are currently six distinct code katas that make up the Eclipse Collections Kata Project on GitHub.
GitHub - eclipse/eclipse-collections-kata: Eclipse Collections Katas
A kata is an exercise in martial arts. A code kata is an exercise in programming which helps hone your skills through…
The katas are the best way to learn the Eclipse Collections library. The Eclipse Collections project started out at the Eclipse Foundation initially with two supporting code katas — the Company Kata and the Pet Kata. These two katas have been used over the past decade to teach thousands of Java developers how to use the Eclipse Collections library. They are still the best katas to start learning Eclipse Collections by doing.
I blogged about the two original Eclipse Collections katas a few years ago.
A Tale of Two Katas
Learn a modern Java Collections Library with more features and less waste.
More doing, more learning
Over the past four years, four more code katas have been added to the Eclipse Collections Kata project. Each kata focuses on a different area of Eclipse Collections. The more Eclipse Collections katas you do, the more you will learn about Eclipse Collections.
I will briefly describe each of the four new Eclipse Collections katas, and what motivated their creation.
The Candy Kata was originally developed to teach Java developers about the
Bag data structure available in Eclipse Collections.
Halloween is a popular holiday in the U.S. Many school aged kids get dressed up in costumes and go around their neighborhoods collecting candy in bags. In my neighborhood, the school kids usually make the rounds collecting bags of candy in different groups. The youngest kids start with their parents early in the afternoon, followed by the middle school kids before sunset, and then finally the high school kids who usually go out in the evening.
This kata has a single test class with two tests that focus on using methods on
I blogged about the Candy Kata on Halloween back in 2018.
Trick or Treat: A Halloween Kata
Learn how to use Eclipse Collections APIs in a fun Java code kata.
Converter Method Kata
The Converter Method Kata started out as a blog that explained how to convert one collection type to another type using Eclipse Collections converter methods. Converter methods are methods that being with the prefix “to” and copy collections contents from one type to another. In order to convert a
List to a
Set in Eclipse Collections, you can call
toSet on the
List. The kinds of converters a developer can learn in this kata are as follows:
- Convert object collections to
- Convert object collections to
- Convert Java Streams to MutableCollection types using Collectors2
- Convert Java Streams to ImmutableCollection types using Collectors2
- Convert primitive collections to other primitive MutableCollection types
I blogged about the converter methods available in Eclipse Collections almost a year ago.
Top Methods Kata
The Top Methods Kata started out as a blog where I wanted to see how many of the Eclipse Collections methods I could include in a single method example. I decided to stop at 25 methods, even though there are a lot more in the
RichIterable interface. We all have limited time, so I wanted to create a kata that a developer could complete that would expose them to the most commonly used methods in the Eclipse Collections API as quickly as possible.
The Top Methods Kata has a single test that you need to complete. There is a test method for each method in the Eclipse Collections API I wanted to include as an example for developers to learn.
Linked here is the original blog which I later turned into the Top Methods Kata.
My 25 favorite methods from the Eclipse Collections API
Out of hundreds of possibilities, these are some of my favorite methods available on the Eclipse Collections API.
Lost and Found Kata
Eclipse Collections is a huge library. The code base has over 1 million lines of code. This makes it a challenge to teach all of the amazing features available in the Eclipse Collections API to developers. A million lines of code is just too much code to just sit down and read. This rather large code base has 18 years of software engineering investment, including contributions from over 100 developers. There are many data structures and algorithms you will not find direct equivalents for in the JDK today.
Nikhil Nanivadekar and I gave a talk on Eclipse Collections to a few hundred software engineers in Amazon at the end of July 2021. In this talk we included examples of several data structures and algorithms that we felt were not generally well known by developers, and had no direct equivalent in the JDK. After delivering this talk, I decided I would write a few blogs going into much more detail about the “missing Java data structures no one ever told you about”. The following blog links to the blog series I wrote in August 2021.
Blog Series: The missing Java data structures no one ever told you about
The three part Eclipse Collections series all in one convenient place.
The Lost and Found Kata was a translation of this blog series into an advanced code kata that can help contributors who are interested learn Eclipse Collections in depth.
The kata is broken into three sections and covers many different data types. I’m including this snapshot of the README.md to show what a developer can potentially learn by completing this kata.
After 18 years of working on Eclipse Collections, I started to feel like I was at risk of forgetting more than I could remember. I wanted to write down as many things that I know or learned, in blogs and katas before the knowledge became only mysterious artifacts buried in a million lines of code. This is why I created this kata. In this kata I am sharing lessons I learned directly with developers in hand-on exercises, hopefully guaranteeing this found knowledge is never at risk of being lost again.
Do. Or do not. There is no Try.
I hope this blog motivates some developers to complete the Eclipse Collections katas. We are looking for more committers for the Eclipse Collections library. If you are interested in investing and committing time to your own learning and the development of the library, then I highly recommend completing the Lost and Found Kata. For more information on becoming a committer on a project managed at the Eclipse Foundation, check out this post on the Eclipse Foundation Wiki.
Development Resources/Becoming a Committer
First and foremost, being a committer on an Eclipse project is an awesome bit of responsibility. Committers have access…
For folks looking for some quick examples to read, or to validate their own solutions to the katas, there are solution modules checked in for each of the katas.
I hope you enjoy these katas! Feedback, improvements and contributions to the katas are amazing and welcome contributions to the library!
I am a Project Lead and Committer for the Eclipse Collections OSS project at the Eclipse Foundation. Eclipse Collections is open for contributions. If you like the library, you can let us know by starring it on GitHub.