Let's start by splitting the address book application into two separate modules. The obvious candidate for moving to its own module is the sorting logic. At this point, there's nothing about the sorting class, SortUtil
, that has anything to do with the address book. We've designed the class to be generic and provide functionality to sort any list. That's good practice in general, but it makes additional sense when breaking it out as a separate module. What we will do is move the code related to sorting into a brand new module, called packt.sortutil
. Here are the steps at a high level:
- Create a new module called
packt.sortutil
. - Move the code related to sorting into this newly created module.
- Configure the
packt.sortutil
module to define its interface--what it exports and how the module needs to be used. - Configure the
packt.addressbook
module to use the newpackt.sortutil
module.
Let's start by creating a new module. We've looked at the four steps to create a module in...