rsm-hcd / AndcultureCode.Cli

and-cli command-line tool to manage the development of software applications
https://andculture.com
Apache License 2.0
14 stars 15 forks source link

Revisit naming & refactoring in CommandRegistry #147

Closed brandongregoryscott closed 3 years ago

brandongregoryscott commented 3 years ago

While the current implementation works, there are some improvements that can be made with the naming and structure of what is currently in the CommandRegistry module.

Some thoughts -

  1. Inside the context of the CommandRegistry, adding Command to a prefixed action (removeCommand, getCommand, etc.) is redundant and add no value. (could be pointed to CLEAN-CODE.md#dont-add-gratuitous-context as an example)
  2. Ensure the distinction between CommandDefinition and program.Command is made and we are not unintentionally swapping the two. While right now the CommandDefinition interface is the primary object we use to register program.Command objects, they are not the same thing, and should not be used interchangeably
  3. A lot of the logic for retrieving, transforming, etc. of CommandDefinitions should be pulled out into a shared module/object. Stuff like mapping, filtering, sorting will quickly be done all over the place and it will be better to consolidate where that is happening. It does not directly relate to the registration of commands, and can be used elsewhere.
  4. Same goes for the retrieval, sorting, mapping of the actual program.Command objects. This might make more sense as a utility class so that it isn't cluttering up the logic in CommandRegistry

This issue is a high level note of the work to be done based on a refactoring session. I expect to be the one that takes this on, but I am more than happy to pair with someone or answer any questions someone might have if they would like to take on some of the work before I get back to it.