Description
ITranslator has many different functions. Many of which don't need to be grouped together.
When writing isolated tests, or dummy translators, it becomes inflexible if a single class has to handle all the functions ITranslator defines. It also makes it impossible to maintain a separation of concerns.
Proposed change:
Simply split ITranslator into multiple smaller interfaces that each define a subset of functions. Then ITranslator becomes empty and just inherits all the new interfaces. It has to be kept around for backwards compatibility.
interface ITextTranslator { }
interface IDocumentTranslator { }
interface ILegacyGlossaryManager { }
interface IUsageManager { }
interface ILanguageManager { }
interface ITranslator : ITextTranslator, IDocumentTranslator, ILegacyGlossaryManager, IUsageManager, ILanguageManager, IDisposable { /*empty*/ }
Naming
- Most names are self explanatory, e.g:
ITextTranslator defines the TranslateTextAsync functions.
ILegacyGlossaryManager defines all the v2 glossary functions. I called it 'legacy' because to refer to the version number would be confusing.
Considerations
Current interfaces like ITranslator and IGlossaryManager require the IDisposable interface. This isn't strictly necessary. There is nothing in their signature that suggests they are responsible for some resource. The only thing that is is Translator and it's derivatives. Therefore I also propose that these new interfaces don't inherit IDisposable.
ITranslator and IGlossaryManager will continue to require it to maintain backwards compatibility.
Description
ITranslatorhas many different functions. Many of which don't need to be grouped together.When writing isolated tests, or dummy translators, it becomes inflexible if a single class has to handle all the functions
ITranslatordefines. It also makes it impossible to maintain a separation of concerns.Proposed change:
Simply split
ITranslatorinto multiple smaller interfaces that each define a subset of functions. ThenITranslatorbecomes empty and just inherits all the new interfaces. It has to be kept around for backwards compatibility.Naming
ITextTranslatordefines theTranslateTextAsyncfunctions.ILegacyGlossaryManagerdefines all the v2 glossary functions. I called it 'legacy' because to refer to the version number would be confusing.Considerations
Current interfaces like
ITranslatorandIGlossaryManagerrequire theIDisposableinterface. This isn't strictly necessary. There is nothing in their signature that suggests they are responsible for some resource. The only thing that is isTranslatorand it's derivatives. Therefore I also propose that these new interfaces don't inheritIDisposable.ITranslatorandIGlossaryManagerwill continue to require it to maintain backwards compatibility.