Step 2 – deciding where to start
It’s now time to decide what to refactor first.
I would recommend not to start with the root command first, but rather with the subcommands of that root command.
There is no right or wrong decision from there. You can pick up any subcommand you would like to start with. We will take the export
command as an example in the remainder of this chapter.
Although the export
command does not have a subcommand, it will still help us lay out the foundation of the refactored version of Bookmarkr. More specifically, it will help us do the following:
- Define the project structure to support our refactoring
- Refactor it and hide its “complexity” (aka moving parts to the root command)
- Refactor the
Program
class and make it leaner, cleaner, and more concise - Set up dependency injection for interacting between commands and external services (such as
BookmarkService
)
Let’s start with designing the project...