Refactoring Data Grouping Operations
Grouping data based on some criteria is a common operation in business applications. We may want to group employees based on their work location, projects based on their business units, products based on their latest revenues, and so on. Creating a Map for the group and adding values for its keys can get verbose in the imperative style and may also involve some inefficiencies. You’ll see a stark contrast between the imperative style version of code that does such processing and its equivalent functional style code.
To gain insight into refactoring code that does grouping operations, we’ll take a collection of hypothetical scores from a game, provided as key-value pairs of player names and scores. Let’s start ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access