A place to put code that is reused by many commands which are part of the [xml-authoring-tools suite](https://github.com/forikal-uk/xml-authoring-tools).
Apache License 2.0
0
stars
0
forks
source link
Extract 'User Config file finding' and 'Google API logic' from `XmlSquad\Library\Command\AbstractCommand` into a 'console helper classes' #6
In the beginning, there were multiple developers building the various commands in the xml-authoring-project.
Consequently, each command had a different way of
offering configuration file and Google API key console options,
reading configuration file and console options, and
finding the configuration file which pointed to the Google API authentication secret key.
I have collected all of those commands into the XmlSquad\Library\Command\AbstractCommand with the aim of de-duplicating the code to unify it so that the user has a consistent interface between commands in the suite.
However, having Commands extending a long chain of abstract Command classes ties down the freedom of the command developer. The OOP best practice is to favour composition of objects rather than structure in order to allow for variations of this type.
So, the answer is to give command writers some kind of 'console helper classes' that can be used to contain and re-use the behaviour associated with:
finding the user's configuration file
finding the user's Google API key, and if applicable, Google API Token File
Google API authentication
How
IT IS UP TO YOU. But, here is a suggestion that considers testing, collaboration and documentation:
Tag the repo's, (project context, xml-authoring-tools and commands), so userland code that uses the current interface has something to hold on to.
Refactor the relevant code out of XmlSquad\Library\Command\AbstractCommand and into a GoogleAPIClientHelper and UserConfigurationFileHelper classes.
Make all commands in the suite use those helpers.
Update tests as needed
Ensure that the command interfaces for finding user configuration and connecting offers consistent options for the user throughout the suite.
Write some documentation to explain how to use the new helpers/ recommend usages.
Tag the repo's, (project context, xml-authoring-tools and commands), so userland code that wants to use the new interface can upgrade to it without breaking code.
Goal
See issue summary
Why
In the beginning, there were multiple developers building the various commands in the xml-authoring-project.
Consequently, each command had a different way of
I have collected all of those commands into the
XmlSquad\Library\Command\AbstractCommand
with the aim of de-duplicating the code to unify it so that the user has a consistent interface between commands in the suite.However, having Commands extending a long chain of abstract Command classes ties down the freedom of the command developer. The OOP best practice is to favour composition of objects rather than structure in order to allow for variations of this type.
So, the answer is to give command writers some kind of 'console helper classes' that can be used to contain and re-use the behaviour associated with:
How
IT IS UP TO YOU. But, here is a suggestion that considers testing, collaboration and documentation:
XmlSquad\Library\Command\AbstractCommand
and into aGoogleAPIClientHelper
andUserConfigurationFileHelper
classes.